diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d61eecc..7fbe531 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,12 @@ name: Build portable releases run-name: >- - Portable release ${{ github.ref_type == 'tag' && github.ref_name || inputs.release_tag || github.ref_name }} + Portable release ${{ github.event.release.tag_name || (github.ref_type == 'tag' && github.ref_name) || inputs.release_tag || github.ref_name }} on: + release: + types: + - published workflow_dispatch: inputs: release_tag: @@ -25,10 +28,13 @@ permissions: jobs: validate: name: Validate source + if: github.event_name != 'release' || github.event.release.prerelease == true runs-on: ubuntu-24.04 timeout-minutes: 30 steps: - uses: actions/checkout@v7 + with: + ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }} - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.14 @@ -66,36 +72,72 @@ jobs: include: - runner: ubuntu-24.04 os: linux + display_os: Linux arch: amd64 suffix: tar.gz - runner: ubuntu-24.04-arm os: linux + display_os: Linux arch: aarch64 suffix: tar.gz - - runner: macos-15-intel - os: darwin - arch: amd64 - suffix: tar.gz - - runner: macos-15 - os: darwin - arch: aarch64 - suffix: tar.gz + # - runner: macos-15-intel + # os: darwin + # display_os: Darwin + # arch: amd64 + # suffix: tar.gz + # - runner: macos-15 + # os: darwin + # display_os: Darwin + # arch: aarch64 + # suffix: tar.gz - runner: windows-2025 os: windows + display_os: Windows arch: amd64 suffix: zip - runner: windows-11-arm os: windows + display_os: Windows arch: aarch64 suffix: zip runs-on: ${{ matrix.runner }} timeout-minutes: 60 steps: - uses: actions/checkout@v7 + with: + ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }} - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.14 - uses: dtolnay/rust-toolchain@stable + - name: Resolve release package name + id: package + shell: bash + env: + REQUESTED_VERSION: ${{ github.event.release.tag_name || (github.ref_type == 'tag' && github.ref_name) || inputs.release_tag }} + run: | + source_version="$(node -p 'require("./package.json").version')" + version="$REQUESTED_VERSION" + if [ -z "$version" ]; then + version="v$source_version" + else + case "$version" in + v*) ;; + *) version="v$version" ;; + esac + fi + + if ! node -e 'process.exit(/^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$/.test(process.argv[1]) ? 0 : 1)' "$version"; then + echo "Invalid release version: $version" >&2 + exit 1 + fi + + if [ "${version#v}" != "$source_version" ]; then + echo "Release version $version does not match project version v$source_version" >&2 + exit 1 + fi + + echo "stem=Easy_CLIProxyAPI-${version}-${{ matrix.display_os }}-${{ matrix.arch }}" >> "$GITHUB_OUTPUT" - name: Install Linux dependencies if: matrix.os == 'linux' run: | @@ -112,7 +154,7 @@ jobs: run: >- node scripts/prepare-portable.mjs --binary "src-tauri/target/release/cpa-gui${{ matrix.os == 'windows' && '.exe' || '' }}" - --output "release/Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}" + --output "release/${{ steps.package.outputs.stem }}" --os "${{ matrix.os }}" --arch "${{ matrix.arch }}" --download true @@ -120,7 +162,7 @@ jobs: - name: Verify archive-only core payload shell: bash env: - CORE_DIR: release/Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}/cpa-core + CORE_DIR: release/${{ steps.package.outputs.stem }}/cpa-core run: | node - <<'NODE' const { readdirSync } = require('node:fs'); @@ -134,21 +176,24 @@ jobs: NODE - name: Archive Unix release if: matrix.os != 'windows' - run: tar -czf "Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}.tar.gz" -C release "Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}" + run: tar -czf "${{ steps.package.outputs.stem }}.tar.gz" -C release "${{ steps.package.outputs.stem }}" - name: Archive Windows release if: matrix.os == 'windows' shell: pwsh - run: Compress-Archive -Path "release/Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}" -DestinationPath "Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}.zip" + run: Compress-Archive -Path "release/${{ steps.package.outputs.stem }}" -DestinationPath "${{ steps.package.outputs.stem }}.zip" - uses: actions/upload-artifact@v7 with: - name: Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }} - path: Easy_CLIProxyAPI-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.suffix }} + name: ${{ steps.package.outputs.stem }} + path: ${{ steps.package.outputs.stem }}.${{ matrix.suffix }} if-no-files-found: error retention-days: 14 publish: name: Publish GitHub release - if: startsWith(github.ref, 'refs/tags/') || inputs.release_tag != '' + if: >- + (github.event_name == 'release' && github.event.release.prerelease == true) + || startsWith(github.ref, 'refs/tags/') + || inputs.release_tag != '' needs: build runs-on: ubuntu-24.04 timeout-minutes: 15 @@ -162,11 +207,16 @@ jobs: env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} - RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || inputs.release_tag }} - MANUAL_PRERELEASE: ${{ inputs.prerelease }} + RELEASE_TAG: ${{ github.event.release.tag_name || (github.ref_type == 'tag' && github.ref_name) || inputs.release_tag }} + MANUAL_PRERELEASE: ${{ github.event_name == 'release' && github.event.release.prerelease || inputs.prerelease }} run: | set -euo pipefail + case "$RELEASE_TAG" in + v*) ;; + *) RELEASE_TAG="v$RELEASE_TAG" ;; + esac + if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then echo "Invalid release tag: $RELEASE_TAG" >&2 exit 1 diff --git a/package.json b/package.json index c08516a..4e3ce5e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cpa-gui", "private": true, - "version": "0.1.0-pre.4", + "version": "0.1.9", "type": "module", "packageManager": "bun@1.3.14", "scripts": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 87b7d24..b26aaed 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -429,7 +429,7 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpa-gui" -version = "0.1.0-pre.4" +version = "0.1.9" dependencies = [ "base64 0.22.1", "chrono", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 10c6bc0..cb21f9c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cpa-gui" -version = "0.1.0-pre.4" +version = "0.1.9" description = "CPA desktop management shell" authors = ["lzt404"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 962f401..5f751be 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Easy_CLIProxyAPI", - "version": "0.1.0-pre.4", + "version": "0.1.9", "identifier": "com.cpa.gui", "build": { "beforeDevCommand": "bun run dev", diff --git a/src/App.tsx b/src/App.tsx index 4b7fcb2..4d53ea3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -168,7 +168,7 @@ function AppContent() {
Easy_CLIProxyAPI - 0.1 + v0.1.9