From 0e57ade95f6ab4303970ee45413c71d82cd1e4f1 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Thu, 11 Dec 2025 13:42:17 +0100 Subject: [PATCH] Separate GitHub Pages publishing to only run on release publish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move GitHub Pages deployment to a separate workflow that triggers only when a release is published, not when drafts are created or updated. The new workflow downloads release assets directly from the published release to deploy alongside the web app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .github/workflows/publish-pages.yml | 84 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 75 -------------------------- 2 files changed, 84 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/publish-pages.yml diff --git a/.github/workflows/publish-pages.yml b/.github/workflows/publish-pages.yml new file mode 100644 index 0000000..a314cea --- /dev/null +++ b/.github/workflows/publish-pages.yml @@ -0,0 +1,84 @@ +name: Publish to GitHub Pages + +on: + release: + types: [published] + +permissions: + contents: read + pages: write + id-token: write + +jobs: + build-web: + name: Build Web App + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build web app + run: npm run build -- --base=/respira/ + + - name: Upload web build artifact + uses: actions/upload-artifact@v4 + with: + name: web-build + path: dist/ + + publish-to-pages: + name: Publish to GitHub Pages + needs: build-web + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Download web build artifact + uses: actions/download-artifact@v4 + with: + name: web-build + path: web-build + + - name: Download release assets + run: | + # Create directory structure + mkdir -p pages/update/win32/x64 + mkdir -p pages/update/darwin/arm64 + + # Copy web build to root + cp -r web-build/* pages/ + + # Download Windows auto-update files from the release + gh release download ${{ github.event.release.tag_name }} --pattern "*.exe" --dir pages/update/win32/x64 + gh release download ${{ github.event.release.tag_name }} --pattern "*.nupkg" --dir pages/update/win32/x64 + gh release download ${{ github.event.release.tag_name }} --pattern "RELEASES" --dir pages/update/win32/x64 + + # Download macOS auto-update files from the release + gh release download ${{ github.event.release.tag_name }} --pattern "*-darwin-arm64-*.zip" --dir pages/update/darwin/arm64 + gh release download ${{ github.event.release.tag_name }} --pattern "RELEASES.json" --dir pages/update/darwin/arm64 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'pages' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f33d52..ba7a938 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,6 @@ on: permissions: contents: write pull-requests: write - pages: write - id-token: write jobs: draft-release: @@ -102,76 +100,3 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-web: - name: Build Web App - needs: draft-release - if: needs.draft-release.outputs.tag-name != '' - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Build web app - run: npm run build -- --base=/respira/ - - - name: Upload web build artifact - uses: actions/upload-artifact@v4 - with: - name: web-build - path: dist/ - - publish-to-pages: - name: Publish to GitHub Pages - needs: [draft-release, build-release, build-web] - if: needs.draft-release.outputs.tag-name != '' - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - steps: - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: Organize files for GitHub Pages - run: | - # Create root directory for web app - mkdir -p pages - - # Copy web build to root - cp -r artifacts/web-build/* pages/ - - # Create update directory structure for auto-update files - mkdir -p pages/update/win32/x64 - mkdir -p pages/update/darwin/arm64 - - # Copy Windows auto-update files - cp artifacts/windows-artifacts/* pages/update/win32/x64/ - - # Copy macOS auto-update files (only ZIP and RELEASES.json, not DMG) - cp artifacts/macos-artifacts/zip/darwin/arm64/*.zip pages/update/darwin/arm64/ - cp artifacts/macos-artifacts/zip/darwin/arm64/RELEASES.json pages/update/darwin/arm64/ - - - name: Setup Pages - uses: actions/configure-pages@v4 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: 'pages' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4