Prevent remove block tasks to be executed on buildings. This is done … #51
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release New Version | |
| # This workflow runs in two stages: | |
| # 1. Automatic: On a tag push, it builds the mod and generates a changelog. | |
| # 2. Manual: After reviewing, you can manually trigger the second stage to publish and release. | |
| on: | |
| push: | |
| tags: | |
| - '1.*.*' | |
| workflow_dispatch: # Allows manual triggering of the 'publish-and-release' job | |
| jobs: | |
| # ==================================================================== | |
| # JOB 1: Build the mod and prepare release assets automatically | |
| # ==================================================================== | |
| build-and-prepare: | |
| name: Build and Prepare Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed for checkout and potentially other steps | |
| packages: write # Needed to publish to GitHub Packages | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required to get all tags for changelog generation | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| server-id: github # for GitHub Packages | |
| settings-path: ${{ github.workspace }} | |
| - name: Set up jq | |
| uses: dcarbone/[email protected] | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| env: | |
| GITHUB_USERNAME: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG_NAME: ${{ github.ref_name }} | |
| - name: Publish to GitHub Packages | |
| run: ./gradlew publishAllPublicationsToGitHubPackagesRepository | |
| env: | |
| GITHUB_USERNAME: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG_NAME: ${{ github.ref_name }} | |
| - name: Retrieve commit messages for changelog | |
| id: get_commits | |
| run: | | |
| commits_list=$(./automation-scripts/prepare-commits-texts.sh) | |
| echo "commits_list<<EOF" >> $GITHUB_OUTPUT | |
| echo "$commits_list" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Generate and Sanitize Release Notes | |
| id: openai | |
| run: | | |
| response=$(./automation-scripts/generate-changelog.sh ${{ secrets.OPENAI_API_KEY }} "${{ steps.get_commits.outputs.commits_list }}" "gpt-4o") | |
| # Extract the content AND pipe it to sed to remove the code block fences | |
| body=$(echo "$response" | jq -r .choices[0].message.content | sed '/^```/d') | |
| echo "Generated and sanitized release body." | |
| # Save the cleaned changelog to a file | |
| echo "$body" > changelog.md | |
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | |
| echo "$body" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-assets-${{ github.ref_name }} | |
| path: | | |
| build/libs/minefortress-*.jar | |
| changelog.md | |
| # ==================================================================== | |
| # JOB 2: Manually triggered job to publish and create the release | |
| # ==================================================================== | |
| publish-and-release: | |
| name: Publish and Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: build-and-prepare # This job can only run if the build job succeeds | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-assets-${{ github.ref_name }} | |
| path: build/libs/ | |
| - name: Display downloaded files | |
| run: ls -R build/libs | |
| - name: Rename changelog for Gradle | |
| run: mv build/libs/changelog.md . | |
| - name: Publish to Modrinth and CurseForge | |
| run: ./gradlew curseforge modrinth | |
| env: | |
| MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
| CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} | |
| TAG_NAME: ${{ github.ref_name }} | |
| - name: Create GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "build/libs/minefortress-*.jar" | |
| tag: ${{ github.ref_name }} | |
| name: MineFortress ${{ github.ref_name }} | |
| bodyFile: "changelog.md" # Use the downloaded changelog file for the release body | |
| prerelease: false | |
| allowUpdates: true | |
| token: ${{ secrets.GITHUB_TOKEN }} |