1a4688a931
Co-authored-by: Cursor <cursoragent@cursor.com>
131 lines
3.8 KiB
YAML
131 lines
3.8 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
BINARY_NAME: polypulse
|
|
MACOSX_DEPLOYMENT_TARGET: "10.15"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.target }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# musl static binaries: run on older Linux without newer GLIBC
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
archive: tar.gz
|
|
musl: true
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
archive: tar.gz
|
|
use_cross: true
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
archive: tar.gz
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
archive: tar.gz
|
|
- target: x86_64-pc-windows-msvc
|
|
os: windows-latest
|
|
archive: zip
|
|
- target: aarch64-pc-windows-msvc
|
|
os: windows-latest
|
|
archive: zip
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Install musl toolchain
|
|
if: matrix.musl == true
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y musl-tools
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.target }}-cargo-
|
|
|
|
- name: Install cross
|
|
if: matrix.use_cross == true
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: cross
|
|
|
|
- name: Build release binary (cross)
|
|
if: matrix.use_cross == true
|
|
run: cross build --release --target ${{ matrix.target }}
|
|
|
|
- name: Build release binary
|
|
if: matrix.use_cross != true
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Prepare release package (Unix)
|
|
if: matrix.archive == 'tar.gz'
|
|
run: |
|
|
VERSION="${GITHUB_REF_NAME#v}"
|
|
PACKAGE="${BINARY_NAME}-${VERSION}-${{ matrix.target }}"
|
|
mkdir -p "dist/${PACKAGE}"
|
|
cp "target/${{ matrix.target }}/release/${BINARY_NAME}" "dist/${PACKAGE}/"
|
|
cp .env.example README.md README.zh-CN.md "dist/${PACKAGE}/"
|
|
tar -czf "dist/${PACKAGE}.tar.gz" -C dist "${PACKAGE}"
|
|
|
|
- name: Prepare release package (Windows)
|
|
if: matrix.archive == 'zip'
|
|
shell: pwsh
|
|
run: |
|
|
$Version = "${{ github.ref_name }}".TrimStart('v')
|
|
$Package = "${{ env.BINARY_NAME }}-${Version}-${{ matrix.target }}"
|
|
New-Item -ItemType Directory -Force -Path "dist/$Package" | Out-Null
|
|
Copy-Item "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" "dist/$Package/"
|
|
Copy-Item .env.example, README.md, README.zh-CN.md "dist/$Package/"
|
|
Compress-Archive -Path "dist/$Package" -DestinationPath "dist/$Package.zip"
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ env.BINARY_NAME }}-${{ matrix.target }}
|
|
path: dist/
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Publish GitHub Release
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: dist
|
|
merge-multiple: true
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
generate_release_notes: true
|
|
files: dist/*
|