From 09055fb6131fc9fa489dd678bfe5051525ed5188 Mon Sep 17 00:00:00 2001 From: James Ward Date: Wed, 5 Aug 2026 02:45:31 -0400 Subject: [PATCH] ci: publish jar / openapi json to release draft (#2243) --- .github/actions/gradle-task/action.yml | 45 ++++++ .github/workflows/release-main.yml | 212 +++++++++++++++++++++++-- 2 files changed, 241 insertions(+), 16 deletions(-) create mode 100644 .github/actions/gradle-task/action.yml diff --git a/.github/actions/gradle-task/action.yml b/.github/actions/gradle-task/action.yml new file mode 100644 index 000000000..bdbd84a7a --- /dev/null +++ b/.github/actions/gradle-task/action.yml @@ -0,0 +1,45 @@ +name: Run Gradle Task +description: Set up the backend toolchain and run a gradle task + +inputs: + app-version: + description: Application version string to include as an environment variable + required: true + working-directory: + description: Directory to change to for running gradle + default: backend/ + gradle-extra-params: + description: Extra parameters for the gradle command + default: "--no-daemon --parallel --build-cache" + task: + description: Gradle Task to Run + required: true + task-extra-params: + description: Extra parameters for the gradle task + +runs: + using: composite + steps: + - name: Set Up JDK 25 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + java-version: '25' + distribution: 'temurin' + cache: gradle + cache-dependency-path: | + **/*.gradle* + **/gradle.lockfile + **/settings.gradle* + **/gradle/wrapper/gradle-wrapper.properties + + - name: Run Gradle Task + shell: bash + working-directory: ${{ inputs.working-directory }} + env: + APP_VERSION: ${{ inputs.app-version }} + GRADLE_TASK: ${{ inputs.task }} + GRADLE_TASK_EXTRA_PARAMS: ${{ inputs.task-extra-params }} + GRADLE_EXTRA_PARAMS: ${{ inputs.gradle-extra-params }} + run: + ./gradlew ${GRADLE_EXTRA_PARAMS} "${GRADLE_TASK}" ${GRADLE_TASK_EXTRA_PARAMS} + diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index f32c28601..10bfb6b19 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -29,11 +29,168 @@ jobs: checkout_ref: ${{ github.sha }} save_gradle_cache: true - semantic-release: - name: Compute Release, Update Changelog, and Draft GitHub Release - needs: [migration-check, test-suite] + semantic-version: + name: Compute Release and Changelog + needs: + - migration-check + - test-suite runs-on: ubuntu-latest + permissions: + contents: read + + outputs: + version: ${{ steps.notes.outputs.predicted_version }} + + steps: + - name: Checkout Repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Record Resolved Commit + id: resolve + env: + GH_TOKEN: ${{ github.token }} + run: | + set -eu + + git fetch origin main --tags --force + base_tag="$(git describe --tags --abbrev=0 --match 'v*' origin/main)" + from_ref="$base_tag" + + echo "base_tag=${base_tag}" >> "$GITHUB_OUTPUT" + echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "from_ref=${from_ref}" >> "$GITHUB_OUTPUT" + + - name: Build Changelog + id: notes + uses: ./.github/actions/compute-release-notes + with: + base_tag: ${{ steps.resolve.outputs.base_tag }} + from_ref: ${{ steps.resolve.outputs.from_ref }} + repository_url: ${{ format('{0}/{1}', github.server_url, github.repository) }} + to_ref: ${{ steps.resolve.outputs.commit_sha }} + + build-frontend: + name: Build frontend + needs: + - semantic-version + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Set Up Node.js + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6 + with: + node-version-file: .nvmrc + + - name: Set Up pnpm + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 + with: + version: 11 + cache: true + run_install: | + - cwd: frontend/ + package_json_file: frontend/package.json + + - name: Build frontend + working-directory: frontend/ + env: + APP_VERSION: ${{ needs.semantic-version.outputs.version }} + run: + pnpm build:prod + + - name: Upload Frontend Artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: frontend + path: frontend/dist/grimmory/browser/ + retention-days: 30 + + build-backend: + name: Build backend + needs: + - semantic-version + - build-frontend + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: frontend + path: /tmp/frontend-dist/ + + - name: Build Backend Jar + uses: ./.github/actions/gradle-task/ + with: + app-version: ${{ needs.semantic-version.outputs.version }} + task: bootJar + task-extra-params: "-PfrontendDistDir=/tmp/frontend-dist" + + - name: Upload Backend Jar Artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: backend + path: backend/build/libs/ + retention-days: 30 + + build-openapi: + name: Build OpenAPI document + needs: + - semantic-version + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Generate OpenAPI JSON + uses: ./.github/actions/gradle-task/ + with: + app-version: ${{ needs.semantic-version.outputs.version }} + task: buildOpenApiArtifacts + + - name: Upload Nightly OpenAPI Artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: openapi + path: backend/build/openapi/ + retention-days: 30 + + draft-release: + name: Create Draft Release + runs-on: ubuntu-latest + needs: + - semantic-version + - build-frontend + - build-backend + - build-openapi + permissions: contents: write @@ -44,24 +201,47 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Install just - uses: taiki-e/install-action@065d6a08a14e61e89fb0a4c10eecdbdef39c7d8e # v2.85.4 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: - tool: just + name: range-release-notes - - name: Set Up pnpm - uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - - - name: Set Up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: - node-version-file: .nvmrc + name: frontend + skip-decompress: true + path: artifacts/ - - name: Install Release Tooling Dependencies - run: just release install + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: backend + path: artifacts/ - - name: Run semantic-release + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: openapi + path: artifacts/ + + - name: Create assets directory + run: | + mkdir -p release-assets/ + + cp artifacts/backend*.jar release-assets/grimmory.jar + cp artifacts/grimmory-openapi.json release-assets/openapi.json + cp artifacts/frontend.zip release-assets/frontend.zip + + - name: Create Draft Release + id: draft-release env: GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }} GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }} - run: just release run + RELEASE_VERSION: ${{ needs.semantic-version.outputs.version }} + TARGET_REF: ${{ github.sha }} + run: | + gh release create \ + "v${RELEASE_VERSION}" \ + --title "Release v${RELEASE_VERSION}" \ + --draft \ + --latest \ + --target "${TARGET_REF}" \ + --notes-file ./range-release-notes.md \ + release-assets/*