name: Project Build run-name: "๐Ÿ“ฆ Project Build #${{ github.run_number }}" on: push: branches: - dev - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: RELEASE_TYPE: "alpha" MINECRAFT_VERSION: "1.20.1" DEV_ENVIRONMENT: ${{ github.ref_name != 'main' }} jobs: info: name: ๐Ÿ–ฅ๏ธ Project Info runs-on: ubuntu-latest outputs: project_version: ${{ steps.check.outputs.version }} project_name: ${{ steps.pakku_info.outputs.name }} project_full_name: ${{ steps.pakku_info.outputs.name }}-${{ steps.check.outputs.version }} changelog: ${{ steps.changelog.outputs.description }} diff: ${{ steps.read_diff.outputs.diff }} exists: ${{ steps.check_tag.outputs.exists }} make_release: ${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'false' }} steps: - name: Checkout uses: actions/checkout@v4.2.2 with: fetch-depth: 0 - name: ๐Ÿ” Check pakku-lock.json id: check_pakku_lock shell: bash run: | if [ ! -f pakku-lock.json ]; then echo "โŒ Could not find pakku-lock.json" && exit 1 else echo "โœ”๏ธ pakku-lock.json" fi - name: ๐Ÿ” Check pakku.json id: check_pakku shell: bash run: | if [ ! -f pakku.json ]; then echo "โŒ Could not find pakku.json" && exit 1 else echo "โœ”๏ธ pakku.json" fi - name: ๐Ÿ“ˆ Get latest tag id: latest_tag shell: bash run: | tag=$(git describe --tags --abbrev=0) if [ -z "$tag" ]; then echo "โŒ Latest tag not found" && exit 1 else echo "โœ”๏ธ Latest tag found: $tag" echo "tag=$tag" >> $GITHUB_OUTPUT fi - name: ๐Ÿ” Check pakku-lock.json in previous tag id: check_pakku_lock_prev shell: bash run: | if git cat-file -e ${{ steps.latest_tag.outputs.tag }}:./pakku-lock.json 2>/dev/null; then echo "โœ”๏ธ File pakku-lock.json found in previous tag" echo "file_found=true" >> $GITHUB_OUTPUT else echo "โŒ File pakku-lock.json not found in previous tag" echo "file_found=false" >> $GITHUB_OUTPUT fi - name: ๐Ÿ“ Check and copy pakku-lock.json from previous tag id: check_copy_lock if: steps.check_pakku_lock_prev.outputs.file_found shell: bash run: | git show tags/${{ steps.latest_tag.outputs.tag }}:./pakku-lock.json > ./pakku-lock-prev.json if [ -s ./pakku-lock-prev.json ]; then echo "โœ”๏ธ File pakku-lock-prev.json created" else echo "โŒ Error: File pakku-lock-prev.json is empty or not created" && exit 1 fi - name: ๐Ÿ“ฆ Download pakku.jar id: download_pakku if: steps.check_pakku_lock_prev.outputs.file_found shell: bash run: | curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J echo "โœ”๏ธ Downloaded pakku.jar " - name: ๐Ÿ”„ Run pakku diff id: pakku_diff if: steps.check_pakku_lock_prev.outputs.file_found shell: bash run: | java -jar pakku.jar diff -v --markdown PROJECTS_DIFF.md ./pakku-lock-prev.json ./pakku-lock.json if [ -f PROJECTS_DIFF.md ]; then echo "โœ”๏ธ Comparison completed" else echo "โŒ Error: File PROJECTS_DIFF.md not created" && exit 1 fi - name: ๐Ÿ“ Read PROJECTS_DIFF.md to variable id: read_diff if: steps.check_pakku_lock_prev.outputs.file_found shell: bash run: | echo "๐Ÿ“ Reading PROJECTS_DIFF.md to variable..." { echo 'diff<> "$GITHUB_OUTPUT" echo "โœ”๏ธ Diff content read to variable" - name: ๐Ÿ“Š Get Pakku Info id: pakku_info uses: ActionsTools/read-json-action@v1.0.5 with: file_path: "pakku.json" - name: ๐Ÿ“Š Get Pakku-lock Info id: pakku_lock_info uses: ActionsTools/read-json-action@v1.0.5 with: file_path: "pakku-lock.json" - name: ๐Ÿ” Check if tag exists uses: mukunku/tag-exists-action@v1.6.0 id: check_tag with: tag: ${{ steps.pakku_info.outputs.version }} - name: ๐Ÿ“ Determine Version id: determine_version shell: bash run: | if [ ${{ env.DEV_ENVIRONMENT }} ]; then echo "version=unreleased" >> $GITHUB_OUTPUT else echo "version=${{ steps.pakku_info.outputs.version }}" >> $GITHUB_OUTPUT fi - name: ๐Ÿ“„ Changelog Parser id: changelog uses: coditory/changelog-parser@v1.0.2 with: path: CHANGELOG.md version: ${{ steps.determine_version.outputs.version }} continue-on-error: true - name: ๐Ÿ” Check if changelog is empty id: check shell: bash run: | if [ ${{ env.DEV_ENVIRONMENT || steps.changelog.outcome == 'failure' }} ]; then echo "version=build_#${{ github.run_number }}" >> $GITHUB_OUTPUT echo "status=Unreleased" >> $GITHUB_OUTPUT else echo "status=${{ env.RELEASE_TYPE }}" >> $GITHUB_OUTPUT echo "version=${{ steps.pakku_info.outputs.version }}" >> $GITHUB_OUTPUT fi - name: ๐Ÿ“„ Format diff id: format_diff if: ${{ steps.read_diff.outputs.diff != '' }} uses: roamingowl/template-output-with-eta@v1.12.0 with: template: | ```markdown ${{ steps.read_diff.outputs.diff }} ``` - name: ๐Ÿ“ Generate Github Summary uses: WcAServices/markdown-template-action@v1.1.1 with: template: | ๐Ÿ“ƒ **Name**: ${{ steps.pakku_info.outputs.name }} ๐Ÿ“ƒ **Release**: `${{ steps.check.outputs.version }}` ๐Ÿ“ƒ **Release Type**: `${{ steps.check.outputs.status }}` ๐Ÿ“ƒ **Game Version**: `${{ steps.pakku_lock_info.outputs.mc_versions }}` ๐Ÿ“ƒ **Dev Environment**: `${{ env.DEV_ENVIRONMENT }}` ๐Ÿ“ƒ **Tag Exists**: `${{ steps.check_tag.outputs.exists }}` ๐Ÿ“ƒ **Make Release**: `${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'false' }}` ${{ steps.changelog.outputs.description }} ${{ steps.format_diff.outputs.text }} build-modpack: name: ๐Ÿ“ฆ Build Modpack needs: [info] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4.2.2 - name: ๐Ÿ”„ Replace strings shell: bash run: | set +e VERSION=${{ needs.info.outputs.project_version }} sed -i -e "s/\"version\": \"[0-9.]*\"/\"version\": \"${VERSION}\"/g" pakku.json sed -i -e "s/DEV/${VERSION}/g" config/fancymenu/customization/gui_main_menu.txt - name: ๐Ÿ“ Cache pakku uses: actions/cache@v4.2.3 id: cache with: path: build/.cache key: pakku-cache-${{ hashFiles('pakku-lock.json') }} restore-keys: pakku-cache- - name: ๐Ÿ“ฆ Export modpack run: | curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J java -jar pakku.jar export - name: ๐Ÿ“ Rename artifact curseforge run: | cd ./build/curseforge/ mv *.zip $(basename -s .zip *.zip)-curseforge.zip - name: ๐Ÿš€ Upload artifact CurseForge uses: actions/upload-artifact@v4.6.2 with: name: ${{ needs.info.outputs.project_full_name }}-curseforge path: ./build/curseforge/${{ needs.info.outputs.project_full_name }}-curseforge.zip if-no-files-found: error - name: ๐Ÿ“ Rename artifact modrinth run: | cd ./build/modrinth/ mv *.mrpack $(basename -s .mrpack *.mrpack)-modrinth.mrpack - name: ๐Ÿš€ Upload artifact modrinth uses: actions/upload-artifact@v4.6.2 with: name: ${{ needs.info.outputs.project_full_name }}-modrinth path: ./build/modrinth/${{ needs.info.outputs.project_full_name }}-modrinth.mrpack if-no-files-found: warn build-server: name: ๐Ÿ“ฆ Build Server needs: [info] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4.2.2 - name: ๐Ÿ”„ Replace strings shell: bash run: | set +e VERSION=${{ needs.info.outputs.project_version }} sed -i -e "s/\"version\": \"[0-9.]*\"/\"version\": \"${VERSION}\"/g" pakku.json sed -i -e "s/DEV/${VERSION}/g" config/fancymenu/customization/gui_main_menu.txt - name: ๐Ÿ“ Cache pakku uses: actions/cache@v4.2.3 id: cache with: path: build/.cache key: pakku-cache-${{ hashFiles('pakku-lock.json') }} restore-keys: pakku-cache- - name: ๐Ÿ“ฆ Export modpack run: | mv -vf ./.pakku/server-overrides/* ./ curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J java -jar pakku.jar export - name: ๐Ÿ“ Rename artifact server run: | cd ./build/serverpack/ mv *.zip $(basename -s .zip *.zip)-serverpack.zip - name: ๐Ÿš€ Upload artifact server uses: actions/upload-artifact@v4.6.2 with: name: ${{ needs.info.outputs.project_full_name }}-serverpack path: ./build/serverpack/${{ needs.info.outputs.project_full_name }}-serverpack.zip if-no-files-found: error build-multimc: name: ๐Ÿ“ฆ Build MultiMC needs: [info] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4.2.2 - name: ๐Ÿ”„ Replace strings shell: bash run: | set +e VERSION=${{ needs.info.outputs.project_version }} sed -i -e "s/\"version\": \"[0-9.]*\"/\"version\": \"${VERSION}\"/g" pakku.json sed -i -e "s/DEV/${VERSION}/g" config/fancymenu/customization/gui_main_menu.txt sed -i -e "s/DEV/${VERSION}/g" .pakku/multimc-overrides/instance.cfg - name: ๐Ÿ“ Cache pakku uses: actions/cache@v4.2.3 id: cache with: path: build/.cache key: pakku-cache-${{ hashFiles('pakku-lock.json') }} restore-keys: pakku-cache- - name: ๐Ÿ“ฆ Export run: | curl https://github.com/juraj-hrivnak/pakku/releases/latest/download/pakku.jar -o pakku.jar -L -J java -jar pakku.jar --debug fetch java -jar pakku.jar --debug export - name: ๐Ÿ“ Move files run: | ls mkdir -p .pakku/multimc-overrides/flame mv -vf ./build/.cache/curseforge/manifest.json .pakku/multimc-overrides/flame/manifest.json mv -vf ./build/.cache/curseforge/overrides .pakku/multimc-overrides/.minecraft mv -vf ./mods/* .pakku/multimc-overrides/.minecraft/mods/ cd .pakku/multimc-overrides/ zip -r ${{ needs.info.outputs.project_full_name }}-multimc.zip icon.png mmc-pack.json instance.cfg .minecraft/ flame/ - name: ๐Ÿš€ Upload zip multimc uses: actions/upload-artifact@v4.6.2 with: name: ${{ needs.info.outputs.project_full_name }}-multimc path: .pakku/multimc-overrides/${{ needs.info.outputs.project_full_name }}-multimc.zip if-no-files-found: error release-github: name: ๐Ÿš€ Release to GitHub needs: [info, build-modpack, build-server, build-multimc] runs-on: ubuntu-latest if: ${{ needs.info.outputs.make_release == 'true' }} outputs: url: ${{ steps.release.outputs.url }} steps: - name: ๐Ÿ“ฆ Checkout uses: actions/checkout@v4.2.2 - name: ๐Ÿ“ฆ Download artifact uses: actions/download-artifact@v4.2.1 with: merge-multiple: true - name: ๐Ÿ” Check if artifact exist id: check_artifact shell: bash run: | if [ ! -f ${{ needs.info.outputs.project_full_name }}-curseforge.zip ]; then echo '::error::No value found for artifact `curseforge.zip`.' && exit 1 fi if [ ! -f ${{ needs.info.outputs.project_full_name }}-modrinth.mrpack ]; then echo '::error::No value found for artifact `modrinth.mrpack`.' && exit 1 fi if [ ! -f ${{ needs.info.outputs.project_full_name }}-serverpack.zip ]; then echo '::error::No value found for artifact `serverpack.zip`.' && exit 1 fi if [ ! -f ${{ needs.info.outputs.project_full_name }}-multimc.zip ]; then echo '::error::No value found for artifact `multimc.zip`.' && exit 1 fi echo "โœ”๏ธ All artifacts found" - name: ๐Ÿšซ ะกlose fixed in dev uses: Xikaro/close-issues-based-on-label@master env: LABEL: "2. Status: In Dev" COMMENT: In ${{ needs.info.outputs.project_version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: ๐Ÿ“„ Format diff id: format_diff if: ${{ needs.info.outputs.diff != '' }} uses: roamingowl/template-output-with-eta@v1.12.0 with: template: | ```markdown ${{ needs.info.outputs.diff }} ``` - name: ๐Ÿš€ Create release id: release uses: softprops/action-gh-release@v2.2.1 with: name: ${{ needs.info.outputs.project_version }} tag_name: ${{ needs.info.outputs.project_version }} target_commitish: ${{ github.ref_name }} body: | ${{ needs.info.outputs.changelog }} ${{ steps.format_diff.outputs.text }} files: | ${{ needs.info.outputs.project_full_name }}-curseforge.zip ${{ needs.info.outputs.project_full_name }}-serverpack.zip ${{ needs.info.outputs.project_full_name }}-multimc.zip prerelease: ${{ env.RELEASE_TYPE != 'release' }} generate_release_notes: true token: ${{ secrets.GITHUB_TOKEN }} release-curseforge: name: ๐Ÿš€ Release to CurseForge needs: [info, build-modpack, build-server, release-github] runs-on: ubuntu-latest if: ${{ needs.info.outputs.make_release == 'true' }} outputs: id: ${{ steps.release.outputs.id }} steps: - name: ๐Ÿ”’ Check if CURSEFORGE_TOKEN exist shell: bash run: | if [ "${{ secrets.CURSEFORGE_TOKEN }}" == '' ]; then echo '::error::No value found for secret key `CURSEFORGE_TOKEN`. See https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository' && exit 1 fi - name: ๐Ÿ“ฆ Download artifact uses: actions/download-artifact@v4.2.1 with: merge-multiple: true - name: ๐Ÿ” Check if artifact exist id: check_artifact shell: bash run: | if [ ! -f ${{ needs.info.outputs.project_full_name }}-curseforge.zip ]; then echo '::error::No value found for artifact `curseforge.zip`.' && exit 1 fi if [ ! -f ${{ needs.info.outputs.project_full_name }}-serverpack.zip ]; then echo '::error::No value found for artifact `serverpack.zip`.' && exit 1 fi echo "โœ”๏ธ All artifacts found" - name: ๐Ÿš€ Upload Curseforge id: release uses: Xikaro/upload-curseforge-modpack-action@1.1.1 with: api-token: ${{ secrets.CURSEFORGE_TOKEN }} project-id: ${{ vars.CURSEFORGE_ID }} display-name: ${{ needs.info.outputs.project_full_name }} modpack-path: ${{ needs.info.outputs.project_full_name }}-curseforge.zip server-display-name: ${{ needs.info.outputs.project_full_name }}-serverpack modpack-server-path: ${{ needs.info.outputs.project_full_name }}-serverpack.zip changelog: | ${{ needs.info.outputs.changelog }} ${{ needs.info.outputs.diff }} changelog-format: markdown game-version: ${{ env.MINECRAFT_VERSION }} release-type: ${{ env.RELEASE_TYPE }} release-modrinth: name: ๐Ÿš€ Release to Modrinth needs: [info, build-modpack, build-server, release-github] runs-on: ubuntu-latest if: false outputs: id: ${{ steps.release.outputs.id }} steps: - name: ๐Ÿ”’ Check if MODRINTH_API_TOKEN exist shell: bash run: | if [ "${{ secrets.MODRINTH_TOKEN }}" == '' ]; then echo '::error::No value found for secret key `MODRINTH_TOKEN`. See https://docs.github.com/en/ actionssecurity-guides/ encrypted-secrets#creating-encrypted-secrets-for-a-repository' && exit 1 fi - name: ๐Ÿ“ฆ Download artifact uses: actions/download-artifact@v4.2.1 with: merge-multiple: true - name: ๐Ÿ” Check if artifact exist id: check_artifact shell: bash run: | if [ ! -f ${{ needs.info.outputs.project_full_name }}-modrinth.mrpack ]; then echo '::error::No value found for artifact `modrinth.mrpack`.' && exit 1 fi if [ ! -f ${{ needs.info.outputs.project_full_name }}-serverpack.zip ]; then echo '::error::No value found for artifact `serverpack.zip`.' && exit 1 fi echo "โœ”๏ธ All artifacts found" - name: ๐Ÿš€ Upload Modrinth id: release uses: Xikaro/upload-curseforge-modpack-action@1.1.1 with: api-token: ${{ secrets.MODRINTH_TOKEN }} project-id: ${{ vars.MODRINTH_ID }} modpack-path: ${{ needs.info.outputs.project_full_name }}-modrinth.mrpack modpack-server-path: ${{ needs.info.outputs.project_full_name }}-serverpack.zip changelog: ${{ needs.info.outputs.changelog }} changelog-format: markdown game-version: ${{ env.MINECRAFT_VERSION }} display-name: ${{ needs.info.outputs.project_full_name }} server-display-name: ${{ needs.info.outputs.project_full_name }}-serverpack release-type: ${{ env.RELEASE_TYPE }} discord-message: name: ๐Ÿ“ฑ Discord Message needs: [info, release-curseforge, release-github] runs-on: ubuntu-latest steps: - name: โœ‚๏ธ Truncate Changelog id: truncated uses: cisox/read-more-action@v1.0.2 with: text: '${{ needs.info.outputs.changelog }}' max_chars: '1450' - name: ๐Ÿ“จ Send Discord message uses: hugoalh/send-discord-webhook-ghaction@v7.0.5 with: key: ${{ secrets.DISCORD_RELEASES }} username: "TerraFirmaGreg" avatar_url: "https://raw.githubusercontent.com/TerraFirmaGreg-Team/.github/main/branding/logo.png" content_links_no_embed: .+ content: | **Release**: `${{ needs.info.outputs.project_version }}` **Release Type**: `${{ env.RELEASE_TYPE }}` **Game Version**: `${{ env.MINECRAFT_VERSION }}` [CurseForge](https://www.curseforge.com/minecraft/modpacks/terrafirmagreg-modern/files/${{ needs.release-curseforge.outputs.id }}) โ€ข [GitHub](${{ needs.release-github.outputs.url }}) โ€ข [Issues](https://github.com/${{ github.repository }}/issues) ```markdown ${{ steps.truncated.outputs.text }} - ...``` ** [Read more...](${{ needs.release-github.outputs.url }}) **