Merge pull request #71 from PrimordialMoros/renovate/gradle-actions-4.x #778
This file contains 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: Build | |
on: | |
push: | |
branches: [ '**' ] | |
tags-ignore: [ '**' ] | |
pull_request: | |
release: | |
types: [ published ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Setup gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
validate-wrappers: true | |
- name: Setup additional gradle cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.gradle/caches/VanillaGradle | |
.gradle/loom-cache | |
paper/.gradle/caches/paperweight | |
key: ${{ runner.os }}-build-cache-${{ hashFiles('**/libs.versions.toml', '**/*.gradle.kts', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-build-cache- | |
- name: Execute gradle build | |
run: ./gradlew build | |
- name: Calculate checksums | |
shell: bash | |
run: | | |
build_dir="build" | |
summary_table="| File | SHA-256 Checksum |\n" | |
summary_table+="|------|------------------|\n" | |
for file in $build_dir/*.jar; do | |
if [[ -f "$file" ]]; then | |
filename=$(basename $file .jar) | |
checksum=$(sha256sum "$file" | cut -c 1-64) | |
summary_table+="| $filename | \`$checksum\` |\n" | |
echo "$checksum" > $build_dir/$filename.sha256 | |
fi | |
done | |
echo -e $summary_table >> $GITHUB_STEP_SUMMARY | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: | | |
build/*.jar | |
build/*.sha256 | |
retention-days: 14 | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event_name == 'release' && github.event.action == 'published' }} | |
steps: | |
- name: Download stored artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
- name: Update release artifacts | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: artifacts/** | |
publish: | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Setup gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
validate-wrappers: true | |
cache-read-only: true | |
add-job-summary: 'on-failure' | |
- name: Generate and submit dependency graph | |
uses: gradle/actions/dependency-submission@v4 | |
- id: status | |
name: Determine status | |
run: ./gradlew printVersionStatus --quiet >> $GITHUB_ENV | |
- name: Publish release to modrinth | |
if: ${{ steps.status.outcome == 'success' && env.STATUS == 'release' }} | |
env: | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
RELEASE_NOTES: ${{ github.event.release.body }} | |
run: ./gradlew modrinth | |
- name: Publish release to hangar | |
if: ${{ steps.status.outcome == 'success' && env.STATUS == 'release' }} | |
env: | |
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }} | |
RELEASE_NOTES: ${{ github.event.release.body }} | |
run: ./gradlew publishAllPublicationsToHangar |