Skip to content

Commit

Permalink
Set Modrinth and Curseforge IDs and try publishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Jan 17, 2025
1 parent 1d86838 commit 59b373a
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/actions/gradle-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Gradle Setup'
description: 'Set up the basics to run gradle'
runs:
using: "composite"
steps:
- name: Export release tag as environment variable
shell: bash
env:
TAG: ${{ github.event.release.tag_name }}
run: |
echo "TAG=${TAG}" >> $GITHUB_ENV
- uses: gradle/actions/wrapper-validation@v3

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 'Build and Test'

on:
push:
# Only on branches, not tags/releases
branches:
- '**'
pull_request:
branches:
- '*'

# Cancel outdated builds for the same branch
concurrency:
group: ci-build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
# Only run the pull-request build if the pull-request was opened from another repository,
# since we already run this workflow for the branch the pull request was made from.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- run: git fetch origin --tags
shell: bash
- uses: ./.github/actions/gradle-setup
- name: Generate assets
run: ./gradlew runData
- name: Check that datagen ran
run: test -d ./src/generated/resources/.cache
- name: Make sure that generated files in the repo are up-to-date
run: |
# Print status for easier debugging
git status
if [ -n "$(git status --porcelain)" ]; then exit 1; fi
# Gradle Step for PRs
- name: Build PR with Gradle
run: ./gradlew build
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
if: github.event_name == 'pull_request'
# Gradle Step for normal branch pushes
- name: Build PR with Gradle
run: ./gradlew build
if: github.event_name != 'pull_request'
- name: Run Game Tests
run: ./gradlew runGametest

# Always upload test results
- name: Merge Test Reports
if: success() || failure()
run: npx junit-report-merger junit.xml "**/TEST-*.xml"

- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results
path: junit.xml

- uses: actions/upload-artifact@v4
with:
name: dist
path: build/libs/
176 changes: 176 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: 'Release'

on:
release:
types: [ published ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
ARTIFACT_PATH: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
ARTIFACT_NAME: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
JAVADOC_PATH: ${{ steps.prepare_artifact_metadata.outputs.JAVADOC_PATH }}
JAVADOC_NAME: ${{ steps.prepare_artifact_metadata.outputs.JAVADOC_NAME }}
API_PATH: ${{ steps.prepare_artifact_metadata.outputs.API_PATH }}
API_NAME: ${{ steps.prepare_artifact_metadata.outputs.API_NAME }}
VERSION: ${{ steps.prepare_artifact_metadata.outputs.VERSION }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- run: git fetch origin --tags
shell: bash
- uses: ./.github/actions/gradle-setup
- name: Build with Gradle
run: ./gradlew printProjectVersion build publish -x check --max-workers 1
- name: Prepare artifact metadata. Note that VERSION is set by the gradle script.
id: prepare_artifact_metadata
run: |
echo ARTIFACT_PATH=./build/libs/guideme-${VERSION}.jar >> $GITHUB_OUTPUT
echo ARTIFACT_NAME=guideme-${VERSION}.jar >> $GITHUB_OUTPUT
echo JAVADOC_PATH=./build/libs/guideme-${VERSION}-javadoc.jar >> $GITHUB_OUTPUT
echo JAVADOC_NAME=guideme-${VERSION}-javadoc.jar >> $GITHUB_OUTPUT
echo API_PATH=./build/libs/guideme-${VERSION}-api.jar >> $GITHUB_OUTPUT
echo API_NAME=guideme-${VERSION}-api.jar >> $GITHUB_OUTPUT
echo VERSION=${VERSION} >> $GITHUB_OUTPUT
- name: Archive build results
run: tar -I zstd -cf build.tar.zst build/libs build/repo
- name: Upload build and gradle folders
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build.tar.zst
if-no-files-found: error
retention-days: 3

upload-release-artifacts:
name: Upload Release Artifacts
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Upload Release Artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ needs.build.outputs.ARTIFACT_PATH }}
asset_name: ${{ needs.build.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- name: Upload Javadocs Artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ needs.build.outputs.JAVADOC_PATH }}
asset_name: ${{ needs.build.outputs.JAVADOC_NAME }}
asset_content_type: application/zip
- name: Upload API
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ needs.build.outputs.API_PATH }}
asset_name: ${{ needs.build.outputs.API_NAME }}
asset_content_type: application/zip

deploy-github-packages:
name: Deploy to Github Packages
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build
- name: Publish to Github Packages
uses: AppliedEnergistics/maven-publish-action@main
with:
local-repository-path: build/repo
remote-repository-url: https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2/
remote-repository-username: ${{ github.actor }}
remote-repository-password: ${{ github.token }}

deploy-curseforge:
name: Deploy to Curseforge
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build
- name: Upload to Curseforge
uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659
with:
name: GuideME ${{ needs.build.outputs.VERSION }}
version: ${{ needs.build.outputs.VERSION }}
files: ${{ needs.build.outputs.ARTIFACT_PATH }}
curseforge-id: 1173950
curseforge-token: ${{ secrets.CURSEFORGE }}
loaders: neoforge

deploy-modmaven:
name: Deploy to Modmaven
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build
- name: Publish to Modmaven
uses: AppliedEnergistics/maven-publish-action@main
with:
local-repository-path: build/repo
remote-repository-url: https://modmaven.dev/artifactory/local-releases/
remote-repository-username: ${{ secrets.MODMAVEN_USER }}
remote-repository-password: ${{ secrets.MODMAVEN_PASSWORD }}

deploy-modrinth:
name: Deploy to Modrinth
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Unpack build artifact
run: tar axf build.tar.zst
- name: Validate artifacts exist
run: test -d ./build
- name: Upload to Modrinth
uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659
with:
name: GuideME ${{ needs.build.outputs.VERSION }}
version: ${{ needs.build.outputs.VERSION }}
files: ${{ needs.build.outputs.ARTIFACT_PATH }}
modrinth-id: Ck4E7v7R
modrinth-token: ${{ secrets.MODRINTH }}
loaders: neoforge
23 changes: 23 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Test Report'
on:
workflow_run:
workflows: ['Build Pull Request']
types:
- completed
permissions:
contents: read
actions: read
checks: write
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@afe6793191b75b608954023a46831a3fe10048d4
with:
artifact: test-results
name: Test Report
path: '**/*.xml'
reporter: java-junit
# This should not affect the result of the check created
# for the origin PR. This just affects this post-processing job itself.
continue-on-error: true
3 changes: 0 additions & 3 deletions buildSrc/src/main/java/ProjectVersionSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public abstract class ProjectVersionSource implements ValueSource<String, Projec
private static final Logger LOG = LoggerFactory.getLogger(ProjectVersionSource.class);

private static final Pattern[] VALID_VERSION_TAGS = {
Pattern.compile("neoforge/v(\\d+\\.\\d+\\.\\d+)(|[+-].*)?"),
Pattern.compile("forge/v(\\d+\\.\\d+\\.\\d+)(|[+-].*)?"),
Pattern.compile("fabric/v(\\d+\\.\\d+\\.\\d+)(|[+-].*)?"),
Pattern.compile("v(\\d+\\.\\d+\\.\\d+)(|[+-].*)?")
};

Expand Down

0 comments on commit 59b373a

Please sign in to comment.