From dce463c6591c2165399ca02353ca27971217595d Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sun, 14 Dec 2025 20:06:51 +0000 Subject: [PATCH] feat: build frontend once and share across platform builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add frontend job that builds Node.js frontend once on ubuntu - Platform builds now download the frontend artifact - New inputs: node-cache-dependency-path, node-output-path, node-embed-path - Reduces build time by avoiding redundant frontend builds on each platform 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .github/workflows/go-release-cgo.yaml | 61 +++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/.github/workflows/go-release-cgo.yaml b/.github/workflows/go-release-cgo.yaml index ae81726..651404c 100644 --- a/.github/workflows/go-release-cgo.yaml +++ b/.github/workflows/go-release-cgo.yaml @@ -30,7 +30,22 @@ on: type: string default: "20" node-build-script: - description: "Shell script to build frontend" + description: "Shell script to build frontend (runs in repo root)" + required: false + type: string + default: "" + node-cache-dependency-path: + description: "Path to package-lock.json for npm caching" + required: false + type: string + default: "package-lock.json" + node-output-path: + description: "Path to frontend build output (for artifact upload)" + required: false + type: string + default: "" + node-embed-path: + description: "Path where frontend should be copied for Go embedding" required: false type: string default: "" @@ -61,6 +76,32 @@ jobs: with: go-version: ${{ inputs.go-version }} + frontend: + name: Build Frontend + if: inputs.node-enabled && inputs.node-build-script != '' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: "npm" + cache-dependency-path: ${{ inputs.node-cache-dependency-path }} + + - name: Build frontend + shell: bash + run: ${{ inputs.node-build-script }} + + - name: Upload frontend artifact + uses: actions/upload-artifact@v4 + with: + name: frontend-dist + path: ${{ inputs.node-output-path }} + retention-days: 1 + version: name: Calculate Version needs: test @@ -82,8 +123,12 @@ jobs: build: name: Build (${{ matrix.platform }}) - needs: version - if: needs.version.outputs.version_tag != '' + needs: [version, frontend] + if: | + always() && + needs.version.result == 'success' && + needs.version.outputs.version_tag != '' && + (needs.frontend.result == 'success' || needs.frontend.result == 'skipped') strategy: fail-fast: false matrix: @@ -101,12 +146,12 @@ jobs: go-version: ${{ inputs.go-version }} cache: true - - name: Build frontend - if: inputs.node-enabled && inputs.node-build-script != '' - uses: lukaszraczylo/shared-actions/.github/actions/node-build@main + - name: Download frontend artifact + if: inputs.node-enabled && inputs.node-embed-path != '' + uses: actions/download-artifact@v4 with: - node-version: ${{ inputs.node-version }} - build-script: ${{ inputs.node-build-script }} + name: frontend-dist + path: ${{ inputs.node-embed-path }} - name: Run GoReleaser (split) uses: lukaszraczylo/shared-actions/.github/actions/goreleaser@main