mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-06-29 05:42:37 +00:00
feat: build frontend once and share across platform builds
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,22 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
default: "20"
|
default: "20"
|
||||||
node-build-script:
|
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
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: ""
|
default: ""
|
||||||
@@ -61,6 +76,32 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: ${{ inputs.go-version }}
|
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:
|
version:
|
||||||
name: Calculate Version
|
name: Calculate Version
|
||||||
needs: test
|
needs: test
|
||||||
@@ -82,8 +123,12 @@ jobs:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build (${{ matrix.platform }})
|
name: Build (${{ matrix.platform }})
|
||||||
needs: version
|
needs: [version, frontend]
|
||||||
if: needs.version.outputs.version_tag != ''
|
if: |
|
||||||
|
always() &&
|
||||||
|
needs.version.result == 'success' &&
|
||||||
|
needs.version.outputs.version_tag != '' &&
|
||||||
|
(needs.frontend.result == 'success' || needs.frontend.result == 'skipped')
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -101,12 +146,12 @@ jobs:
|
|||||||
go-version: ${{ inputs.go-version }}
|
go-version: ${{ inputs.go-version }}
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Build frontend
|
- name: Download frontend artifact
|
||||||
if: inputs.node-enabled && inputs.node-build-script != ''
|
if: inputs.node-enabled && inputs.node-embed-path != ''
|
||||||
uses: lukaszraczylo/shared-actions/.github/actions/node-build@main
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ inputs.node-version }}
|
name: frontend-dist
|
||||||
build-script: ${{ inputs.node-build-script }}
|
path: ${{ inputs.node-embed-path }}
|
||||||
|
|
||||||
- name: Run GoReleaser (split)
|
- name: Run GoReleaser (split)
|
||||||
uses: lukaszraczylo/shared-actions/.github/actions/goreleaser@main
|
uses: lukaszraczylo/shared-actions/.github/actions/goreleaser@main
|
||||||
|
|||||||
Reference in New Issue
Block a user