mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
156 lines
4.6 KiB
YAML
156 lines
4.6 KiB
YAML
name: Release CLI
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- cli-v*
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: release-cli-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
resolve:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
tag: ${{ steps.version.outputs.tag }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Resolve CLI version
|
|
id: version
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
VERSION="$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')"
|
|
else
|
|
VERSION="${GITHUB_REF_NAME#cli-v}"
|
|
fi
|
|
VERSION="${VERSION#v}"
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "tag=cli-v${VERSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
guard:
|
|
needs: resolve
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Verify tag matches Cargo.toml workspace version
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
CARGO_VERSION="$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')"
|
|
RELEASE_VERSION="${{ needs.resolve.outputs.version }}"
|
|
if [ "$CARGO_VERSION" != "$RELEASE_VERSION" ]; then
|
|
echo "Cargo.toml version (${CARGO_VERSION}) does not match release version (${RELEASE_VERSION})"
|
|
exit 1
|
|
fi
|
|
echo "Version guard passed: ${RELEASE_VERSION}"
|
|
|
|
build-cli:
|
|
needs: [resolve, guard]
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
archive: tar.gz
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
archive: tar.gz
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
archive: tar.gz
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-24.04-arm
|
|
archive: tar.gz
|
|
- target: x86_64-pc-windows-msvc
|
|
os: windows-latest
|
|
archive: zip
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Install musl tools (Linux)
|
|
if: runner.os == 'Linux'
|
|
shell: bash
|
|
run: sudo apt-get update && sudo apt-get install -y musl-tools
|
|
|
|
- name: Build bsk
|
|
shell: bash
|
|
run: cargo build --release --locked -p bsk --target "${{ matrix.target }}"
|
|
|
|
- name: Package archive (Unix)
|
|
if: matrix.archive == 'tar.gz'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
VERSION="${{ needs.resolve.outputs.version }}"
|
|
ARCHIVE="bsk-v${VERSION}-${{ matrix.target }}.tar.gz"
|
|
tar -czf "$ARCHIVE" -C "target/${{ matrix.target }}/release" bsk
|
|
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
|
|
|
|
- name: Package archive (Windows)
|
|
if: matrix.archive == 'zip'
|
|
shell: pwsh
|
|
run: |
|
|
$version = "${{ needs.resolve.outputs.version }}"
|
|
$archive = "bsk-v${version}-${{ matrix.target }}.zip"
|
|
Compress-Archive -Path "target/${{ matrix.target }}/release/bsk.exe" -DestinationPath $archive -Force
|
|
"ARCHIVE=$archive" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: bsk-${{ matrix.target }}
|
|
path: ${{ env.ARCHIVE }}
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
needs: [resolve, build-cli]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
path: dist
|
|
merge-multiple: true
|
|
|
|
- name: Render version.json
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
node scripts/render-version-json.mjs \
|
|
--version "${{ needs.resolve.outputs.version }}" \
|
|
--repo "${{ github.repository }}" \
|
|
--server-url "${{ github.server_url }}" \
|
|
--branch "${{ github.event.repository.default_branch }}" \
|
|
--dist dist \
|
|
--out dist/version.json
|
|
|
|
- name: Publish GitHub Release
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
tag_name: ${{ needs.resolve.outputs.tag }}
|
|
name: bsk CLI ${{ needs.resolve.outputs.version }}
|
|
make_latest: true
|
|
generate_release_notes: true
|
|
files: |
|
|
dist/*.tar.gz
|
|
dist/*.zip
|
|
dist/version.json
|