diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c87fdaf..e5e2b24 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,16 +11,23 @@ on: jobs: generate_matrix: uses: ./.github/workflows/generate_matrix.yml - release: + create_github_release: runs-on: ubuntu-24.04 - strategy: - matrix: ${{ fromJSON(needs.generate_matrix.outputs.matrix) }} needs: - generate_matrix # Allow the mod publish step to add assets to release # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token permissions: contents: write + outputs: + commit_count: ${{ steps.shared_publish_info.outputs.commit_count }} + github_changelog: ${{ steps.changelog.outputs.result }} + github_tag: ${{ steps.shared_publish_info.outputs.github_tag }} + mod_name: ${{ steps.shared_publish_info.outputs.mod_name }} + mod_version: ${{ steps.shared_publish_info.outputs.mod_version }} + mod_full_version: ${{ steps.shared_publish_info.outputs.mod_version }} + release_title: ${{ steps.shared_publish_info.outputs.release_title }} + short_sha: ${{ steps.shared_publish_info.outputs.short_sha }} steps: - name: Checkout the sources uses: actions/checkout@v4 @@ -78,14 +85,6 @@ jobs: echo "mod_version=$mod_version" >> $GITHUB_OUTPUT echo "mod_full_version=$mod_full_version" >> $GITHUB_OUTPUT echo "release_title=$release_title" >> $GITHUB_OUTPUT - - name: Get publish info - id: publish_info - run: | - pip install jproperties - python .github/workflows/scripts/publish_info.py - env: - MOD_PLATFORM: ${{ matrix.platform }} - MOD_MC_VER: ${{ matrix.mc_ver }} - name: Prepare changelog uses: actions/github-script@v7 id: changelog @@ -106,11 +105,57 @@ jobs: Latest commit log: ${{ github.event.head_commit.message }} + - name: Publish Minecraft Mods (Dev Channel) + if: ${{ inputs.publish_type == 'dev' }} + uses: Kir-Antipov/mc-publish@v3.3 + with: + github-tag: ${{ steps.shared_publish_info.outputs.github_tag }} + github-token: ${{ secrets.GITHUB_TOKEN }} + github-changelog: ${{ steps.changelog.outputs.result }} + github-prerelease: true + files: build-artifacts/versions/**/build/libs/!(*-@(dev|sources|javadoc)).jar + name: ${{ steps.shared_publish_info.outputs.release_title }} + retry-attempts: 3 + retry-delay: 10000 + - name: Publish Minecraft Mods (Stable Channel) + if: ${{ inputs.publish_channel == 'stable' }} + uses: Kir-Antipov/mc-publish@v3.3 + with: + github-tag: ${{ steps.shared_publish_info.outputs.github_tag }} + github-token: ${{ secrets.GITHUB_TOKEN }} + files: build-artifacts/versions/**/build/libs/!(*-@(dev|sources|javadoc)).jar + retry-attempts: 3 + retry-delay: 10000 + create_platform_release: + runs-on: ubuntu-24.04 + strategy: + matrix: ${{ fromJSON(needs.generate_matrix.outputs.matrix) }} + needs: + - generate_matrix + - create_github_release + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: build-artifacts + - name: Get publish info + id: publish_info + run: | + pip install jproperties + python .github/workflows/scripts/publish_info.py + env: + MOD_PLATFORM: ${{ matrix.platform }} + MOD_MC_VER: ${{ matrix.mc_ver }} - name: Prepare file information id: file_info run: | shopt -s extglob - FILE_PATHS=$(ls ${{ format('build-artifacts/versions//{0}-{1}/build/libs/!(*-@(dev|sources|javadoc)).jar', matrix.mc_ver, matrix.platform) }}) + FILE_PATHS=$(ls ${{ format('build-artifacts/versions/{0}-{1}/build/libs/!(*-@(dev|sources|javadoc)).jar', matrix.mc_ver, matrix.platform) }}) if (( ${#FILE_PATHS[@]} != 1 )); then echo "Error: Found ${#FILE_PATHS[@]} files, expected exactly 1" @@ -127,13 +172,13 @@ jobs: cat $GITHUB_OUTPUT - name: Attach file info to changelog uses: actions/github-script@v7 - id: changelog_platform + id: changelog with: script: return process.env.CHANGELOG result-encoding: string env: CHANGELOG: |- - ${{ steps.changelog.outputs.result }} + ${{ needs.release_core.outputs.github_changelog }} ------- @@ -150,17 +195,10 @@ jobs: modrinth-token: ${{ secrets.MODRINTH || '${undefined}' }} curseforge-id: '${undefined}' curseforge-token: ${{ secrets.CF_API_TOKEN || '${undefined}' }} - github-tag: ${{ steps.shared_publish_info.outputs.github_tag }} - github-token: ${{ secrets.GITHUB_TOKEN }} - github-changelog: ${{ steps.changelog.outputs.result }} - github-prerelease: true files: ${{ steps.file_info.outputs.path }} - curseforge-changelog: ${{ steps.changelog_platform.outputs.result }} - curseforge-name: ${{ steps.shared_publish_info.outputs.release_title }} - modrinth-changelog: ${{ steps.changelog_platform.outputs.result }} - modrinth-name: ${{ steps.shared_publish_info.outputs.release_title }} - name: ${{ steps.shared_publish_info.outputs.release_title }} - version: ${{ format('v{0}.{1}-mc{2}-{3}', steps.shared_publish_info.outputs.mod_version, steps.shared_publish_info.outputs.commit_count, matrix.mc_ver, matrix.platform) }} + changelog: ${{ steps.changelog.outputs.result }} + name: ${{ needs.create_github_release.outputs.release_title }} + version: ${{ format('v{0}.{1}-mc{2}-{3}', needs.create_github_release.outputs.mod_version, needs.create_github_release.outputs.commit_count, matrix.mc_ver, matrix.platform) }} version-type: alpha loaders: ${{ steps.publish_info.outputs.publish_loaders }} game-versions: ${{ steps.publish_info.outputs.publish_game_versions }} @@ -176,15 +214,10 @@ jobs: modrinth-token: ${{ secrets.MODRINTH || '${undefined}' }} curseforge-id: 525510 curseforge-token: ${{ secrets.CF_API_TOKEN || '${undefined}' }} - github-tag: ${{ steps.shared_publish_info.outputs.github_tag }} - github-token: ${{ secrets.GITHUB_TOKEN }} files: ${{ steps.file_info.outputs.path }} - curseforge-changelog: ${{ steps.changelog_platform.outputs.result }} - curseforge-name: ${{ steps.shared_publish_info.outputs.release_title }} - modrinth-changelog: ${{ steps.changelog_platform.outputs.result }} - modrinth-name: ${{ steps.shared_publish_info.outputs.release_title }} - name: ${{ steps.shared_publish_info.outputs.release_title }} - version: ${{ format('v{0}.{1}-mc{2}-{3}', steps.shared_publish_info.outputs.mod_version, steps.shared_publish_info.outputs.commit_count, matrix.mc_ver, matrix.platform) }} + changelog: ${{ steps.changelog.outputs.result }} + name: ${{ needs.create_github_release.outputs.release_title }} + version: ${{ format('v{0}.{1}-mc{2}-{3}', needs.create_github_release.outputs.mod_version, needs.create_github_release.outputs.commit_count, matrix.mc_ver, matrix.platform) }} version-type: ${{ github.event.release.prerelease && 'beta' || 'release' }} loaders: ${{ steps.publish_info.outputs.publish_loaders }} game-versions: ${{ steps.publish_info.outputs.publish_game_versions }}