Skip to content

build

build #249

Workflow file for this run

name: build
on:
push:
branches:
- 'master'
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
force_nightly:
description: 'Force nightly build (upload artifacts and send Discord notification)'
required: false
type: boolean
default: false
jobs:
generate-build-matrix:
runs-on: ubuntu-latest
name: Generate build matrix
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Generate matrix from versions.json
id: generate-matrix
run: |
MATRIX=$(jq -c '{include: (.branches[""] | map({target: .}))}' ./versions/versions.json)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
build:
needs: generate-build-matrix
runs-on: ubuntu-latest
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-build-matrix.outputs.matrix) }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Temurin JDK 21 with Gradle cache
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: gradle
cache-dependency-path: |
**/*.gradle*
**/gradle-wrapper.properties
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
- name: Sanitize artifact name
run: |
raw="${{ matrix.target }}"
clean="${raw%%:*}"
echo "ARTIFACT_NAME=$clean" >> $GITHUB_ENV
- name: Build ${{ matrix.target }}
run: |
./gradlew "${{ env.ARTIFACT_NAME }}:build" --no-daemon --stacktrace
- name: Upload build artifacts
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.force_nightly == 'true')
uses: actions/upload-artifact@v4
with:
name: yoinkgui-${{ env.ARTIFACT_NAME }}-${{ github.run_number }}
path: versions/${{ env.ARTIFACT_NAME }}/build/libs/*.jar
retention-days: 30
notify:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.force_nightly == 'true')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Send Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
COMMIT_MSG=$(git log -1 --pretty=%B | head -n 1)
COMMIT_SHA=$(git rev-parse --short HEAD)
curl -H "Content-Type: application/json" \
-d "{\"embeds\": [{\"title\": \"🌙 Nightly Build Complete\", \"description\": \"YoinkGUI nightly build has finished successfully!\", \"color\": 5814783, \"fields\": [{\"name\": \"Commit\", \"value\": \"[\`$COMMIT_SHA\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) - $COMMIT_MSG\", \"inline\": false}, {\"name\": \"Download\", \"value\": \"[Click here to download artifacts]($ARTIFACT_URL)\", \"inline\": false}], \"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}]}" \
$DISCORD_WEBHOOK