Create Release with ShadowJars #16
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: Create Release with ShadowJars | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build ShadowJars and Create Release | |
| runs-on: blacksmith-4vcpu-ubuntu-2204 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: develop | |
| fetch-depth: 0 # Added to fetch all tags | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'adopt' | |
| java-version: '21' | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| gradle-${{ runner.os }} | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| - name: Build ShadowJars | |
| run: ./gradlew clean build shadowJar | |
| - name: Get Gradle Version and Commit Hash | |
| id: vars | |
| shell: bash | |
| run: | | |
| echo "version=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_OUTPUT | |
| echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| echo "date=$(date +%y%m%d-%H%M)" >> $GITHUB_OUTPUT | |
| - name: Publish to Modrinth | |
| run: ./gradlew modrinth && ./gradlew modrinthSyncBody | |
| env: | |
| COMMIT_HASH: ${{ steps.vars.outputs.commit }} | |
| MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: v${{ steps.vars.outputs.version }}-dev.${{ steps.vars.outputs.commit }}-${{ steps.vars.outputs.date }} | |
| release_name: v${{ steps.vars.outputs.version }}-dev.${{ steps.vars.outputs.commit }} | |
| draft: false | |
| prerelease: true | |
| commitish: develop | |
| body: | | |
| This release contains dev builds for all Gradle modules. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload ShadowJars to Release | |
| run: | | |
| for jar in $(find . -type f -name "*.jar" -path "*/build/libs/*.jar" -not -path "./build/libs/*"); do | |
| if [[ $(basename "$jar") =~ -[0-9]+\.[0-9]+ ]]; then | |
| echo "Skipping $jar due to version number" | |
| else | |
| echo "Uploading $jar" | |
| gh release upload v${{ steps.vars.outputs.version }}-dev.${{ steps.vars.outputs.commit }}-${{ steps.vars.outputs.date }} "$jar" | |
| fi | |
| done | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |