Build #117
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: | |
- main | |
paths: | |
- '**.java' | |
- 'src/main/resources/**' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '**.java' | |
- 'src/main/resources/**' | |
workflow_dispatch: | |
inputs: | |
upload_artifact: | |
description: 'Upload artifact to this run? [y | n]' | |
required: false | |
default: 'n' | |
send_notification: | |
description: 'Send a notification to Discord after this run finishes successfully? [y | n]' | |
required: false | |
default: 'n' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 20 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Download translations from Crowdin | |
uses: crowdin/github-action@v1 | |
with: | |
skip_ref_checkout: true | |
download_translations: true | |
export_only_approved: true | |
push_translations: false | |
upload_sources: false | |
env: | |
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | |
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | |
- name: Fix ownership of Gradle build directory | |
run: '[ -d build ] && sudo chown -R $(whoami):$(id -gn) build || echo "Skipped, build directory does not exist."' | |
- name: Build with Gradle | |
run: gradle build --no-daemon | |
- name: Read Project Version | |
id: read_project_version | |
if: ${{ github.ref_name == 'main' || contains(github.event.inputs.upload_artifact, 'y') }} | |
uses: christian-draeger/[email protected] | |
with: | |
path: gradle.properties | |
properties: version | |
- name: Upload Artifact | |
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || contains(github.event.inputs.upload_artifact, 'y') }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Fancy Warp Menu | |
path: build/libs/* | |
- name: Get Pushed Commit Messages | |
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "COMMIT_LOG<<$EOF" >> "$GITHUB_ENV" | |
echo "$(git log -n 20 --format=format:"%aD%n%B" ${{ github.event.before }}..${{ github.event.after }})" >> "$GITHUB_ENV" | |
echo "$EOF" >> "$GITHUB_ENV" | |
- name: Get Head Commit Message | |
if: ${{ env.COMMIT_LOG == '' }} | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "COMMIT_LOG<<$EOF" >> "$GITHUB_ENV" | |
echo "$(git show -s --format=format:"%B")" >> "$GITHUB_ENV" | |
echo "$EOF" >> "$GITHUB_ENV" | |
- name: Post Build Information to Discord | |
if: ${{ (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch' && contains(github.event.inputs.send_notification, 'y') }} | |
env: | |
jarPath: build/libs/FancyWarpMenu-${{ steps.read_project_version.outputs.version }}+${{ github.run_number }}.jar | |
uses: tsickert/[email protected] | |
with: | |
webhook-url: ${{ secrets.BUILD_WEBHOOK_URL }} | |
# New build notifications role | |
content: <@&1124879006597140481> | |
embed-title: ${{ steps.read_project_version.outputs.version }} Build \#${{ github.run_number }} | |
embed-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/ | |
embed-description: | | |
${{ env.COMMIT_LOG }} | |
[File SHA-256](https://emn178.github.io/online-tools/sha256_checksum.html 'Drop jar onto linked site and verify hash matches the one below.') below ([what's this?](https://github.com/BiscuitDevelopment/SkyblockAddons/wiki/How-to-Verify-the-File-Hash)) | |
embed-footer-text: ${{ hashFiles(env.jarPath) }} | |
filename: ${{ env.jarPath }} |