[π¦]: Project Build #71 #71
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: "Project Build" | |
| run-name: "[π¦]: Project Build #${{ github.run_number }}" | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| paths: | |
| - 'gradle/**' | |
| - 'src/**' | |
| - '*.gradle' | |
| - 'gradle.properties' | |
| - 'CHANGELOG.md' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| info: | |
| name: "[π₯οΈ] Project Info" | |
| runs-on: ubuntu-latest | |
| if: ${{ !github.event.repository.fork }} | |
| outputs: | |
| name: ${{ steps.check.outputs.name }} | |
| version: ${{ steps.check.outputs.version }} | |
| version_type: ${{ steps.check.outputs.version_type }} | |
| full_name: ${{ steps.check.outputs.name }}-${{ steps.check.outputs.version }} | |
| loaders: ${{ steps.check.outputs.loaders }} | |
| game_versions: ${{ steps.check.outputs.game_versions }} | |
| java_version: ${{ steps.check.outputs.java_version }} | |
| make_release: ${{ steps.check.outputs.make_release }} | |
| steps: | |
| - name: "[π¦] Checkout" | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: "[π] Check required files and folders" | |
| uses: andstor/file-existence-action@v3.1.0 | |
| with: | |
| fail: true | |
| ignore_case: true | |
| files: "gradle.properties, build.gradle, LICENSE, README.md, src" | |
| - name: "[π₯] Get Project Info" | |
| id: project_info | |
| uses: madhead/read-java-properties@latest | |
| with: | |
| file: gradle.properties | |
| all: true | |
| - name: "[π] Check if tag exists" | |
| uses: mukunku/tag-exists-action@v1.7.0 | |
| id: tag_check | |
| with: | |
| tag: ${{ steps.project_info.outputs.mod_version }} | |
| - name: "[π] Check" | |
| id: check | |
| shell: bash | |
| run: | | |
| # Get data from previous steps | |
| TAG_EXISTS="${{ steps.tag_check.outputs.exists }}" | |
| PROJECT_NAME="${{ steps.project_info.outputs.mod_name }}-${{ steps.project_info.outputs.mod_name_suffix }}" | |
| GAME_VERSIONS="${{ steps.project_info.outputs.minecraft_version }}" | |
| JAVA_VERSION="${{ steps.project_info.outputs.java_version }}" | |
| LOADERS="${{ steps.project_info.outputs.loader }}" | |
| LOADERS_VERSION="${{ steps.project_info.outputs.forge_version }}" | |
| # Preparation | |
| IS_RELEASE_CANDIDATE="false" | |
| if [[ "$TAG_EXISTS" == "false" && -n "${{ steps.project_info.outputs.mod_version }}" ]]; then | |
| IS_RELEASE_CANDIDATE="true" | |
| fi | |
| if [[ "$IS_RELEASE_CANDIDATE" == "true" ]]; then | |
| PROJECT_VERSION="${{ steps.project_info.outputs.mod_version }}" | |
| PROJECT_VERSION_TYPE="${{ steps.project_info.outputs.mod_version_type }}" | |
| else | |
| PROJECT_VERSION="${{ steps.project_info.outputs.mod_version }}-build-${{ github.run_number }}" | |
| PROJECT_VERSION_TYPE="Unreleased" | |
| fi | |
| # Save values for next steps | |
| echo "game_version=$GAME_VERSIONS" >> $GITHUB_OUTPUT | |
| echo "java_version=$JAVA_VERSION" >> $GITHUB_OUTPUT | |
| echo "loaders=$LOADERS" >> $GITHUB_OUTPUT | |
| echo "loaders_version=$LOADERS_VERSION" >> $GITHUB_OUTPUT | |
| echo "name=$PROJECT_NAME" >> $GITHUB_OUTPUT | |
| echo "version=$PROJECT_VERSION" >> $GITHUB_OUTPUT | |
| echo "version_type=$PROJECT_VERSION_TYPE" >> $GITHUB_OUTPUT | |
| echo "exists=$TAG_EXISTS" >> $GITHUB_OUTPUT | |
| echo "make_release=$IS_RELEASE_CANDIDATE" >> $GITHUB_OUTPUT | |
| - name: "[π] Generate Build Summary" | |
| uses: WcAServices/markdown-template-action@v1.1.1 | |
| with: | |
| template: | | |
| ## π Build Information | |
| ### Project Info | |
| | Parameter | Value | | |
| |-----------|-------| | |
| | π **Name** | `${{ steps.check.outputs.name }}` | | |
| | π **Version** | `${{ steps.check.outputs.version }}` | | |
| | π **Release Type** | `${{ steps.check.outputs.version_type }}` | | |
| | π **Game Versions** | `${{ steps.check.outputs.game_version }}` | | |
| | π **Loaders** | `${{ steps.check.outputs.loaders }}` | | |
| | π **Loaders Version** | `${{ steps.check.outputs.loaders_version }}` | | |
| ### Build Decision | |
| | Parameter | Value | | |
| |-----------|-------| | |
| | π **Tag Exists** | `${{ steps.check.outputs.exists }}` | | |
| | π **Make Release** | `${{ steps.check.outputs.make_release }}` | | |
| build: | |
| name: "[π¦] Build Project" | |
| needs: [info] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "[π¦] Checkout" | |
| uses: actions/checkout@v6 | |
| - name: "[π] Replace" | |
| shell: bash | |
| run: | | |
| VERSION="${{ needs.info.outputs.version }}" | |
| if [ ! -f gradle.properties ]; then | |
| echo "::error::gradle.properties not found" | |
| exit 1 | |
| fi | |
| sed -i "s/^mod_version[[:space:]]*=.*/mod_version = ${VERSION}/g" gradle.properties | |
| - name: "[π] Setup Java" | |
| uses: actions/setup-java@v5.2.0 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ needs.info.outputs.java_version }} | |
| cache: 'gradle' | |
| - name: "[π] Prepare artifact" | |
| run: | | |
| chmod +x gradlew | |
| ./gradlew build -x spotlessCheck | |
| ls -la build/libs/ | |
| - name: "[π] Upload Artifact" | |
| uses: actions/upload-artifact@v7.0.1 | |
| with: | |
| name: ${{ needs.info.outputs.full_name }} | |
| path: build/libs/${{ needs.info.outputs.full_name }}.jar | |
| if-no-files-found: error | |
| release: | |
| name: "[π] Release" | |
| needs: [info, build] | |
| runs-on: ubuntu-latest | |
| if: ${{ needs.info.outputs.make_release == 'true' }} | |
| steps: | |
| - name: "[π¦] Debug make_release" | |
| run: | | |
| echo "make_release = '${{ needs.info.outputs.make_release }}'" | |
| echo "Comparison result: ${{ needs.info.outputs.make_release == 'true' }}" | |
| - name: "[π¦] Download artifact" | |
| uses: actions/download-artifact@v8 | |
| - name: "[π] Verify" | |
| shell: bash | |
| run: | | |
| echo "=== Token Verification ===" | |
| if [ -z "${{ secrets.MODRINTH_TOKEN }}" ]; then | |
| echo "::error::MODRINTH_TOKEN not found" | |
| exit 1 | |
| fi | |
| echo "β MODRINTH_TOKEN: OK" | |
| if [ -z "${{ secrets.CURSEFORGE_TOKEN }}" ]; then | |
| echo "::error::CURSEFORGE_TOKEN not found" | |
| exit 1 | |
| fi | |
| echo "β CURSEFORGE_TOKEN: OK" | |
| echo "" | |
| echo "=== ID Verification ===" | |
| if [ -z "${{ vars.MODRINTH_ID }}" ]; then | |
| echo "::error::MODRINTH_ID not found" | |
| exit 1 | |
| fi | |
| echo "β MODRINTH_ID: OK" | |
| if [ -z "${{ vars.CURSEFORGE_ID }}" ]; then | |
| echo "::error::CURSEFORGE_ID not found" | |
| exit 1 | |
| fi | |
| echo "β CURSEFORGE_ID: OK" | |
| echo "" | |
| echo "=== Artifact Verification ===" | |
| if [ ! -f "${{ needs.info.outputs.full_name }}.jar" ]; then | |
| echo "::error::Artifact not found" | |
| ls -la | |
| exit 1 | |
| fi | |
| echo "β Artifact: OK" | |
| echo "" | |
| - name: "[π] Release" | |
| uses: Xikaro/game-publish@3.3.3 | |
| with: | |
| modrinth-id: ${{ vars.MODRINTH_ID }} | |
| modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
| curseforge-id: ${{ vars.CURSEFORGE_ID }} | |
| curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
| github-name: ${{ needs.info.outputs.version }} | |
| github-tag: ${{ needs.info.outputs.version }} | |
| github-generate-changelog: true | |
| github-draft: false | |
| github-prerelease: ${{ needs.info.outputs.version_type != 'release' }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| files: ${{ needs.info.outputs.full_name }}.jar | |
| name: ${{ needs.info.outputs.full_name }} | |
| version: ${{ needs.info.outputs.version }} | |
| version-type: ${{ needs.info.outputs.version_type }} | |
| # changelog: ${{ needs.info.outputs.changelog }} | |
| loaders: ${{ needs.info.outputs.loaders }} | |
| game-versions: ${{ needs.info.outputs.game_versions }} | |
| game-version-filter: none | |
| java: ${{ needs.info.outputs.java_version }} | |
| retry-attempts: 2 | |
| retry-delay: 10000 | |
| fail-mode: fail |