ci: stabilize release workflow setup

This commit is contained in:
lpf
2026-03-12 13:18:57 +08:00
parent 1eca901503
commit 1775b0ec86
2 changed files with 154 additions and 12 deletions

View File

@@ -67,9 +67,114 @@ jobs:
echo "Targets: $build_targets"
echo "Variants: $channel_variants"
build-and-package:
build-webui:
needs: prepare-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ensure Node.js 20
shell: bash
run: |
set -euo pipefail
if command -v node >/dev/null 2>&1; then
node_major="$(node -p 'process.versions.node.split(".")[0]')"
else
node_major=""
fi
if [ "$node_major" != "20" ]; then
arch="$(dpkg --print-architecture)"
case "$arch" in
amd64) node_arch="x64" ;;
arm64) node_arch="arm64" ;;
*)
echo "Unsupported runner architecture for Node install: $arch" >&2
exit 1
;;
esac
curl -fsSL "https://nodejs.org/dist/v20.19.5/node-v20.19.5-linux-${node_arch}.tar.xz" -o /tmp/node.tar.xz
sudo rm -rf /usr/local/lib/nodejs
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJf /tmp/node.tar.xz -C /usr/local/lib/nodejs
echo "/usr/local/lib/nodejs/node-v20.19.5-linux-${node_arch}/bin" >> "$GITHUB_PATH"
fi
node --version
npm --version
- name: Install WebUI dependencies
shell: bash
run: |
set -euo pipefail
cd webui
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Build WebUI
shell: bash
run: |
set -euo pipefail
make build-webui
- name: Upload WebUI dist
uses: actions/upload-artifact@v4
with:
name: webui-dist
path: webui/dist
if-no-files-found: error
prepare-go-cache:
needs: prepare-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
shell: bash
run: |
set -euo pipefail
go_version="$(awk '/^go / {print $2; exit}' go.mod)"
arch="$(dpkg --print-architecture)"
case "$arch" in
amd64) go_arch="amd64" ;;
arm64) go_arch="arm64" ;;
*)
echo "Unsupported runner architecture for Go install: $arch" >&2
exit 1
;;
esac
curl -fsSL "https://go.dev/dl/go${go_version}.linux-${go_arch}.tar.gz" -o /tmp/go.tgz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go.tgz
echo "/usr/local/go/bin" >> "$GITHUB_PATH"
/usr/local/go/bin/go version
- name: Warm Go module cache
shell: bash
run: |
set -euo pipefail
mkdir -p /tmp/go-cache
go mod download
GOMODCACHE="$(go env GOMODCACHE)"
tar -C "$GOMODCACHE" -czf /tmp/go-cache/gomodcache.tar.gz .
- name: Upload Go module cache
uses: actions/upload-artifact@v4
with:
name: go-mod-cache
path: /tmp/go-cache/gomodcache.tar.gz
if-no-files-found: error
build-and-package:
needs:
- prepare-release
- build-webui
- prepare-go-cache
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
@@ -78,18 +183,45 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Install Go
shell: bash
run: |
set -euo pipefail
go_version="$(awk '/^go / {print $2; exit}' go.mod)"
arch="$(dpkg --print-architecture)"
case "$arch" in
amd64) go_arch="amd64" ;;
arm64) go_arch="arm64" ;;
*)
echo "Unsupported runner architecture for Go install: $arch" >&2
exit 1
;;
esac
curl -fsSL "https://go.dev/dl/go${go_version}.linux-${go_arch}.tar.gz" -o /tmp/go.tgz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go.tgz
echo "/usr/local/go/bin" >> "$GITHUB_PATH"
/usr/local/go/bin/go version
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Download WebUI dist
uses: actions/download-artifact@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: webui/package-lock.json
name: webui-dist
path: webui/dist
- name: Download Go module cache
uses: actions/download-artifact@v4
with:
name: go-mod-cache
path: /tmp/go-cache
- name: Restore Go module cache
shell: bash
run: |
set -euo pipefail
GOMODCACHE="$(go env GOMODCACHE)"
mkdir -p "$GOMODCACHE"
tar -C "$GOMODCACHE" -xzf /tmp/go-cache/gomodcache.tar.gz
- name: Install packaging tools
run: |
@@ -116,7 +248,8 @@ jobs:
make package-all \
VERSION="${{ needs.prepare-release.outputs.version }}" \
BUILD_TARGETS="${{ matrix.target }}" \
CHANNEL_PACKAGE_VARIANTS="${{ needs.prepare-release.outputs.channel_variants }}"
CHANNEL_PACKAGE_VARIANTS="${{ needs.prepare-release.outputs.channel_variants }}" \
SKIP_WEBUI_BUILD=1
rm -f build/checksums.txt
- name: Upload matrix artifacts