π¦ Project Build #21 #21
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 | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| RELEASE_TYPE: "release" | |
| DEV_ENVIRONMENT: ${{ github.ref_name != 'main' }} | |
| jobs: | |
| info: | |
| name: π₯οΈ Project Info | |
| runs-on: ubuntu-latest | |
| outputs: | |
| project_version: ${{ steps.project_version.outputs.value }} | |
| project_name: ${{ steps.check.outputs.project_name }} | |
| project_full_name: ${{ steps.check.outputs.project_name }}-${{ steps.check.outputs.project_version }} | |
| minecraft_version: ${{ steps.check.outputs.minecraft_version }} | |
| java_version: ${{ steps.check.outputs.java_version }} | |
| exists: ${{ steps.check.outputs.exists }} | |
| make_release: ${{ steps.check.outputs.make_release }} | |
| steps: | |
| - name: π Checkout | |
| uses: actions/[email protected] | |
| with: | |
| fetch-depth: 0 | |
| - name: π₯ Get Project Name | |
| id: project_name | |
| uses: dschanoeh/[email protected] | |
| with: | |
| file: gradle.properties | |
| property: mod_name | |
| - name: π₯ Get Project Name Suffix | |
| id: project_name_suffix | |
| uses: dschanoeh/[email protected] | |
| with: | |
| file: gradle.properties | |
| property: mod_name_suffix | |
| - name: π₯ Get Project Version | |
| id: project_version | |
| uses: dschanoeh/[email protected] | |
| with: | |
| file: gradle.properties | |
| property: mod_version | |
| - name: π₯ Get Minecraft Version | |
| id: minecraft_version | |
| uses: dschanoeh/[email protected] | |
| with: | |
| file: gradle.properties | |
| property: minecraft_version | |
| - name: π₯ Get Java Version | |
| id: java_version | |
| uses: dschanoeh/[email protected] | |
| with: | |
| file: gradle.properties | |
| property: java_version | |
| - name: π Check If Tag Exists | |
| uses: mukunku/[email protected] | |
| id: check_tag | |
| with: | |
| tag: ${{ steps.project_version.outputs.value }} | |
| - name: π Check | |
| id: check | |
| shell: bash | |
| run: | | |
| echo "make_release=${{ steps.check_tag.outputs.exists == 'false' && env.DEV_ENVIRONMENT == 'false' }}" >> $GITHUB_OUTPUT | |
| echo "exists=${{ steps.check_tag.outputs.exists }}" >> $GITHUB_OUTPUT | |
| echo "project_name=${{ steps.project_name.outputs.value }}-${{ steps.project_name_suffix.outputs.value }}" >> $GITHUB_OUTPUT | |
| echo "project_version=${{ steps.project_version.outputs.value }}" >> $GITHUB_OUTPUT | |
| echo "release_type=${{ env.RELEASE_TYPE }}" >> $GITHUB_OUTPUT | |
| echo "minecraft_version=${{ steps.minecraft_version.outputs.value }}" >> $GITHUB_OUTPUT | |
| echo "java_version=${{ steps.java_version.outputs.value }}" >> $GITHUB_OUTPUT | |
| if ${{ env.DEV_ENVIRONMENT == 'true' }}; then | |
| echo "project_version=build_#${{ github.run_number }}" >> $GITHUB_OUTPUT | |
| echo "release_type=Unreleased" >> $GITHUB_OUTPUT | |
| fi | |
| - name: π Generate Github Summary | |
| uses: WcAServices/[email protected] | |
| with: | |
| template: | | |
| π **Name**: ${{ steps.check.outputs.project_name }} | |
| π **Release**: `${{ steps.check.outputs.project_version }}` | |
| π **Release Type**: `${{ steps.check.outputs.release_type }}` | |
| π **Game Version**: `${{ steps.check.outputs.minecraft_version }}` | |
| π **Dev Environment**: `${{ env.DEV_ENVIRONMENT }}` | |
| π **Tag Exists**: `${{ steps.check.outputs.exists }}` | |
| π **Make Release**: `${{ steps.check.outputs.make_release }}` | |
| build: | |
| name: π¦ Build Mod | |
| needs: [info] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: π Checkout | |
| uses: actions/[email protected] | |
| - name: π Setup JDK | |
| uses: actions/[email protected] | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ needs.info.outputs.java_version }} | |
| - name: π Setup Gradle | |
| uses: gradle/actions/[email protected] | |
| with: | |
| cache-cleanup: always | |
| cache-disabled: true | |
| - name: π Grant Execute Permission For Gradlew | |
| run: chmod +x gradlew | |
| - name: π¦ Build | |
| run: ./gradlew build -x spotlessCheck | |
| - name: π¦ Rename Jar | |
| shell: bash | |
| run: | | |
| if ${{ env.DEV_ENVIRONMENT == 'true' }}; then | |
| mv build/libs/${{ needs.info.outputs.project_name }}-${{ needs.info.outputs.project_version }}.jar build/libs/${{ needs.info.outputs.project_full_name }}.jar | |
| fi | |
| - name: π Upload Artifact Jar | |
| uses: actions/[email protected] | |
| with: | |
| name: ${{ needs.info.outputs.project_full_name }} | |
| path: build/libs/${{ needs.info.outputs.project_full_name }}.jar | |
| if-no-files-found: warn | |
| release: | |
| name: π Release | |
| needs: [info, build] | |
| runs-on: ubuntu-latest | |
| if: ${{ needs.info.outputs.make_release == 'true' }} | |
| steps: | |
| - name: π¦ Checkout | |
| uses: actions/[email protected] | |
| - 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/[email protected] | |
| with: | |
| merge-multiple: true | |
| - name: π Check if artifact exist | |
| id: check_artifact | |
| shell: bash | |
| run: | | |
| if [ ! -f ${{ needs.info.outputs.project_full_name }}.jar ]; then | |
| echo '::error::No value found for artifact `curseforge.zip`.' && exit 1 | |
| fi | |
| echo "βοΈ All artifacts found" | |
| - name: π Release | |
| uses: Xikaro/[email protected] | |
| with: | |
| modrinth-id: ${{ vars.MODRINTH_ID }} | |
| modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
| modrinth-dependencies: | | |
| JaCEZUhg(required) | |
| 7tG215v7(required) | |
| curseforge-id: ${{ vars.CURSEFORGE_ID }} | |
| curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
| curseforge-dependencies: | | |
| gregtechceu-modern(required) | |
| terrafirmacraft(required) | |
| github-name: ${{ needs.info.outputs.project_version }} | |
| github-tag: ${{ needs.info.outputs.project_version }} | |
| github-generate-changelog: true | |
| github-draft: false | |
| github-prerelease: ${{ env.RELEASE_TYPE != 'release' }} | |
| github-commitish: main | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| files: ${{ needs.info.outputs.project_full_name }}.jar | |
| name: "${{ needs.info.outputs.project_full_name }}" | |
| version: ${{ needs.info.outputs.project_version }} | |
| version-type: ${{ env.RELEASE_TYPE }} | |
| loaders: | | |
| forge | |
| neoforge | |
| game-versions: ${{ needs.info.outputs.minecraft_version }} | |
| game-version-filter: none | |
| java: ${{ needs.info.outputs.java_version }} | |
| retry-attempts: 2 | |
| retry-delay: 10000 | |
| fail-mode: fail |