ci: add GitHub Actions workflow for releasing binaries
- Add .github/workflows/release.yml - Build binaries for multiple platforms (linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64) - Embed frontend into binary - Generate SHA256 checksums for each binary - Automatically release on tag push
This commit is contained in:
92
.github/workflows/release.yml
vendored
Normal file
92
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
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'
|
||||
cache: 'pnpm'
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Install pnpm
|
||||
run: npm install -g pnpm
|
||||
|
||||
- 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
|
||||
Reference in New Issue
Block a user