Files
ushare/.github/workflows/release.yml
loveuer 96fe642175 fix: correct pnpm setup in GitHub Actions
- Use pnpm/action-setup@v2 instead of npm install -g
- Add proper pnpm cache configuration
- Fix 'Unable to locate executable file: pnpm' error
2026-01-18 17:35:34 +08:00

107 lines
2.7 KiB
YAML

name: Release Binaries
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
suffix: linux-amd64
- goos: linux
goarch: arm64
suffix: linux-arm64
- goos: darwin
goarch: amd64
suffix: darwin-amd64
- goos: darwin
goarch: arm64
suffix: darwin-arm64
- goos: windows
goarch: amd64
suffix: windows-amd64
ext: .exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Print build info
run: |
echo "Tag: ${{ github.ref_name }}"
echo "GoOS: ${{ matrix.goos }}"
echo "GoArch: ${{ matrix.goarch }}"
- name: Build frontend
working-directory: frontend
run: |
pnpm install --registry=https://registry.npmmirror.com
pnpm run build
- name: Copy frontend dist for embedding
run: |
mkdir -p internal/static/frontend
cp -r frontend/dist internal/static/frontend/
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
OUTPUT_NAME="ushare-${{ matrix.suffix }}${{ matrix.ext }}"
go build -ldflags '-s -w' -o "$OUTPUT_NAME" .
chmod +x "$OUTPUT_NAME"
- name: Generate checksums
run: |
OUTPUT_NAME="ushare-${{ matrix.suffix }}${{ matrix.ext }}"
sha256sum "$OUTPUT_NAME" > "$OUTPUT_NAME.sha256"
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
files: |
ushare-${{ matrix.suffix }}${{ matrix.ext }}
ushare-${{ matrix.suffix }}${{ matrix.ext }}.sha256
draft: false
prerelease: false