|
| 1 | +name: step.publish |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + publish_channel: |
| 6 | + type: string |
| 7 | + required: true |
| 8 | + publish_mc_ver: |
| 9 | + type: string |
| 10 | + required: true |
| 11 | + publish_platform: |
| 12 | + type: string |
| 13 | + required: true |
| 14 | + publish_target_release_tag: |
| 15 | + description: |- |
| 16 | + The tag of the release you want to append the artifact to. |
| 17 | + type: string |
| 18 | + required: true |
| 19 | +jobs: |
| 20 | + publish: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + # Allow the mod publish step to add asserts to release |
| 23 | + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token |
| 24 | + permissions: |
| 25 | + contents: write |
| 26 | + steps: |
| 27 | + - name: Checkout the sources |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + - name: Download build artifacts |
| 32 | + uses: actions/download-artifact@v4 |
| 33 | + with: |
| 34 | + name: build-artifacts |
| 35 | + path: build-artifacts |
| 36 | + - name: Get git info |
| 37 | + id: get_git_info |
| 38 | + run: | |
| 39 | + short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) |
| 40 | + commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l) |
| 41 | + echo "short_sha=$short_sha" >> $GITHUB_OUTPUT |
| 42 | + echo "commit_count=$commit_count" >> $GITHUB_OUTPUT |
| 43 | + - name: Read Properties mod info |
| 44 | + id: mod_info |
| 45 | + uses: christian-draeger/read-properties@1.1.1 |
| 46 | + with: |
| 47 | + path: gradle.properties |
| 48 | + properties: 'mod.name mod.version' |
| 49 | + - name: Publish Minecraft Mods (Dev Channel) |
| 50 | + if: ${{ inputs.publish_channel == 'dev' }} |
| 51 | + uses: Kir-Antipov/mc-publish@v3.3 |
| 52 | + with: |
| 53 | + # modrinth-id: |
| 54 | + # modrinth-token: ${{ secrets.MODRINTH_API_TOKEN }} |
| 55 | + # curseforge-id: |
| 56 | + # curseforge-token: ${{ secrets.CF_API_TOKEN }} |
| 57 | + github-tag: ${{ github.ref_name }}.${{ steps.get_git_info.outputs.commit_count }} |
| 58 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + github-prerelease: true |
| 60 | + github-generate-changelog: true |
| 61 | + github-files: | |
| 62 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar |
| 63 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar |
| 64 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar |
| 65 | + files: | |
| 66 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar |
| 67 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar |
| 68 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar |
| 69 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar |
| 70 | + name: '[CI#${{ github.run_number }}]${{ steps.mod_info.outputs.mod-name }} ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}' |
| 71 | + version: ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }} |
| 72 | + version-type: alpha |
| 73 | + changelog: | |
| 74 | + **This version is automatically released by CI Build** |
| 75 | + Latest commit log: |
| 76 | + ${{ github.event.head_commit.message }} |
| 77 | + loaders: | |
| 78 | + ${{ inputs.publish_platform }} |
| 79 | + game-versions: | |
| 80 | + ${{ inputs.publish_mc_ver }} |
| 81 | + game-version-filter: any |
| 82 | + dependencies: | |
| 83 | + carpet(optional) |
| 84 | + malilib(optional) |
| 85 | + retry-attempts: 2 |
| 86 | + retry-delay: 10000 |
| 87 | + - name: Publish Minecraft Mods (Stable Channel) |
| 88 | + if: ${{ inputs.publish_channel == 'stable' }} |
| 89 | + uses: Kir-Antipov/mc-publish@v3.3 |
| 90 | + with: |
| 91 | + # modrinth-id: |
| 92 | + # modrinth-token: ${{ secrets.MODRINTH_API_TOKEN }} |
| 93 | + # curseforge-id: |
| 94 | + # curseforge-token: ${{ secrets.CF_API_TOKEN }} |
| 95 | + github-tag: ${{ inputs.publish_target_release_tag }} |
| 96 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + github-generate-changelog: true |
| 98 | + github-files: | |
| 99 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar |
| 100 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar |
| 101 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar |
| 102 | + files: | |
| 103 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar |
| 104 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar |
| 105 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar |
| 106 | + build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar |
| 107 | + name: '${{ steps.mod_info.outputs.mod-name }} ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}' |
| 108 | + version: ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }} |
| 109 | + version-type: release |
| 110 | + changelog: ${{ github.event.release.body }} |
| 111 | + loaders: | |
| 112 | + ${{ inputs.publish_platform }} |
| 113 | + game-versions: | |
| 114 | + ${{ inputs.publish_mc_ver }} |
| 115 | + game-version-filter: any |
| 116 | + dependencies: | |
| 117 | + carpet(optional) |
| 118 | + malilib(optional) |
| 119 | + retry-attempts: 2 |
| 120 | + retry-delay: 10000 |
0 commit comments