mirror of
https://github.com/feigeCode/navop.git
synced 2026-10-08 08:01:00 +00:00
264 lines
8.5 KiB
YAML
264 lines
8.5 KiB
YAML
name: Release
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
name: Build (${{ matrix.target }})
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
binary: onetcli
|
|
archive: onetcli-aarch64-apple-darwin.tar.gz
|
|
- target: x86_64-apple-darwin
|
|
os: macos-15-intel
|
|
binary: onetcli
|
|
archive: onetcli-x86_64-apple-darwin.tar.gz
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
binary: onetcli
|
|
archive: onetcli-x86_64-unknown-linux-gnu.tar.gz
|
|
- target: aarch64-unknown-linux-gnu
|
|
os: ubuntu-24.04-arm
|
|
binary: onetcli
|
|
archive: onetcli-aarch64-unknown-linux-gnu.tar.gz
|
|
- target: x86_64-pc-windows-msvc
|
|
os: windows-latest
|
|
binary: onetcli.exe
|
|
archive: onetcli-x86_64-pc-windows-msvc.zip
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust toolchain
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
with:
|
|
target: ${{ matrix.target }}
|
|
|
|
|
|
- name: Free disk space (macOS)
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
df -h
|
|
|
|
remove_path() {
|
|
local path="$1"
|
|
if [ -e "$path" ]; then
|
|
sudo rm -rf "$path" || echo "::warning::Failed to remove $path"
|
|
fi
|
|
}
|
|
|
|
remove_directory_contents() {
|
|
local path="$1"
|
|
if [ -d "$path" ]; then
|
|
sudo find "$path" -mindepth 1 -maxdepth 1 -exec rm -rf {} + \
|
|
|| echo "::warning::Failed to remove some entries under $path"
|
|
fi
|
|
}
|
|
|
|
remove_path /usr/local/lib/node_modules
|
|
remove_path "$HOME/.npm"
|
|
remove_path "$HOME/.nvm"
|
|
remove_directory_contents "$HOME/Library/Caches"
|
|
remove_path /System/Library/Frameworks/Python.framework
|
|
|
|
df -h
|
|
|
|
- name: Install system dependencies (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: script/bootstrap
|
|
|
|
- name: Install system dependencies (macOS)
|
|
if: runner.os == 'macOS'
|
|
run: script/bootstrap
|
|
|
|
- name: Install system dependencies (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
cmake --version
|
|
|
|
- name: Cache Cargo
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
key: build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
build-${{ matrix.target }}-
|
|
|
|
- name: Set environment variables
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ github.ref_type }}" == "tag" ]]; then
|
|
VERSION="${{ github.ref_name }}"
|
|
VERSION="${VERSION#v}"
|
|
echo "ONETCLI_VERSION=${VERSION}" >> "$GITHUB_ENV"
|
|
else
|
|
echo "ONETCLI_VERSION=0.0.0-dev.$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
|
fi
|
|
|
|
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
|
|
echo "CARGO_BUILD_JOBS=1" >> "$GITHUB_ENV"
|
|
echo "CARGO_PROFILE_RELEASE_LTO=false" >> "$GITHUB_ENV"
|
|
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16" >> "$GITHUB_ENV"
|
|
fi
|
|
|
|
- name: Verify secrets are set
|
|
shell: bash
|
|
env:
|
|
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
|
|
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
|
|
run: |
|
|
if [ -z "$SUPABASE_URL" ]; then
|
|
echo "::error::SUPABASE_URL secret is empty or not set"
|
|
exit 1
|
|
fi
|
|
if [ -z "$SUPABASE_ANON_KEY" ]; then
|
|
echo "::error::SUPABASE_ANON_KEY secret is empty or not set"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build release binary
|
|
env:
|
|
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
|
|
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
|
|
ONETCLI_PUBLIC_BASE_URL: ${{ vars.ONETCLI_PUBLIC_BASE_URL }}
|
|
ONETCLI_EXTENSION_GITHUB_MANIFEST_URL: ${{ vars.ONETCLI_EXTENSION_GITHUB_MANIFEST_URL }}
|
|
ONETCLI_WECHAT_QR_URL: ${{ secrets.ONETCLI_WECHAT_QR_URL }}
|
|
ONETCLI_ALIPAY_QR_URL: ${{ secrets.ONETCLI_ALIPAY_QR_URL }}
|
|
ONETCLI_PAYPAL_QR_URL: ${{ secrets.ONETCLI_PAYPAL_QR_URL }}
|
|
run: |
|
|
cargo --version
|
|
rustc --version
|
|
echo "CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-}"
|
|
echo "CARGO_PROFILE_RELEASE_LTO=${CARGO_PROFILE_RELEASE_LTO:-}"
|
|
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${CARGO_PROFILE_RELEASE_CODEGEN_UNITS:-}"
|
|
cargo build --release -p main --target ${{ matrix.target }}
|
|
|
|
|
|
- name: Clean build artifacts (macOS)
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
rm -rf target/debug
|
|
find target -name "incremental" -o -name "deps" -o -name "build" | xargs rm -rf || true
|
|
rm -rf ~/.cargo/registry/cache ~/.cargo/git/db
|
|
df -h
|
|
|
|
- name: Create macOS app bundle
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
chmod +x script/bundle-macos.sh
|
|
chmod +x script/bundle-macos-dmg.sh
|
|
script/bundle-macos.sh ${{ matrix.target }}
|
|
script/bundle-macos-dmg.sh ${{ matrix.target }}
|
|
tar czf ${{ matrix.archive }} -C target OnetCli.app
|
|
|
|
- name: Package (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
mkdir -p package/usr/bin
|
|
mkdir -p package/usr/share/applications
|
|
mkdir -p package/usr/share/icons/hicolor/128x128/apps
|
|
mkdir -p package/usr/share/icons/hicolor/256x256/apps
|
|
mkdir -p package/usr/share/icons/hicolor/512x515/apps
|
|
cp target/${{ matrix.target }}/release/${{ matrix.binary }} package/usr/bin/
|
|
cp resources/linux/onetcli.desktop package/usr/share/applications/
|
|
cp resources/linux/onetcli-128.png package/usr/share/icons/hicolor/128x128/apps/onetcli.png
|
|
cp resources/linux/onetcli-256.png package/usr/share/icons/hicolor/256x256/apps/onetcli.png
|
|
cp resources/linux/onetcli-512.png package/usr/share/icons/hicolor/512x515/apps/onetcli.png
|
|
tar czf ${{ matrix.archive }} -C package .
|
|
|
|
- name: Package (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -ItemType Directory -Force package | Out-Null
|
|
Copy-Item "target/${{ matrix.target }}/release/${{ matrix.binary }}" "package/${{ matrix.binary }}"
|
|
Compress-Archive -Path "package/*" -DestinationPath "${{ matrix.archive }}"
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.archive }}
|
|
path: ${{ matrix.archive }}
|
|
|
|
- name: Upload macOS DMG artifact
|
|
if: runner.os == 'macOS'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: onetcli-${{ matrix.target }}.dmg
|
|
path: "*.dmg"
|
|
|
|
release:
|
|
name: Create Release
|
|
needs: build
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: List artifacts
|
|
run: ls -la artifacts/
|
|
|
|
- name: Generate checksums
|
|
run: |
|
|
cd artifacts
|
|
sha256sum onetcli-* > sha256sums.txt
|
|
cat sha256sums.txt
|
|
|
|
- name: Write release metadata
|
|
run: |
|
|
node <<'NODE'
|
|
const fs = require("fs");
|
|
const releaseTag = process.env.GITHUB_REF_NAME;
|
|
const version = releaseTag.replace(/^v/, "");
|
|
fs.writeFileSync(
|
|
"artifacts/release-metadata.json",
|
|
`${JSON.stringify({ release_tag: releaseTag, version }, null, 2)}\n`,
|
|
);
|
|
NODE
|
|
|
|
- name: Upload release metadata
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-metadata
|
|
path: artifacts/release-metadata.json
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
name: OnetCli ${{ github.ref_name }}
|
|
generate_release_notes: true
|
|
files: |
|
|
artifacts/onetcli-*.tar.gz
|
|
artifacts/onetcli-*.zip
|
|
artifacts/onetcli-*.dmg
|
|
artifacts/sha256sums.txt
|