chore(ci): add release.yml workflow_dispatch

This commit is contained in:
晨苒
2026-04-16 18:38:02 +08:00
parent d3a820b2dc
commit 7aa6ec6ca9
+39 -10
View File
@@ -4,18 +4,27 @@ on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag_name:
description: "Existing release tag to rebuild, e.g. v0.7.0"
required: true
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
group: ${{ github.workflow }}-${{ github.event.inputs.tag_name || github.ref_name }}
cancel-in-progress: false
env:
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.ref_name }}
jobs:
changelog:
name: Generate changelog
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
with:
@@ -27,7 +36,7 @@ jobs:
with:
node-version: lts/*
registry-url: https://registry.npmjs.org/
- run: pnpm dlx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -75,7 +84,7 @@ jobs:
TARGET_ARCH: ${{ matrix.goarch }}
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
VERSION="${RELEASE_TAG#v}"
bash scripts/release.sh \
--version "$VERSION" \
--commit-hash "$COMMIT_HASH" \
@@ -95,6 +104,7 @@ jobs:
name: Upload CLI artifacts
runs-on: ubuntu-latest
needs: [changelog, cli-build]
if: ${{ always() && needs.cli-build.result == 'success' && (needs.changelog.result == 'success' || needs.changelog.result == 'skipped') }}
steps:
- name: Download CLI artifacts
uses: actions/download-artifact@v4
@@ -106,10 +116,17 @@ jobs:
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ env.RELEASE_TAG }}
run: |
set -euo pipefail
gh release upload "$TAG_NAME" release-artifacts/cli/*.tar.gz release-artifacts/cli/*.zip --clobber
shopt -s nullglob
files=(release-artifacts/cli/*.tar.gz release-artifacts/cli/*.zip)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No CLI artifacts found" >&2
exit 1
fi
gh release upload "$TAG_NAME" "${files[@]}" --clobber --repo "$GH_REPO"
desktop-build:
name: Build desktop ${{ matrix.target }}
@@ -136,7 +153,7 @@ jobs:
shell: bash
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
VERSION="${RELEASE_TAG#v}"
export VERSION
node <<'EOF'
const fs = require('fs');
@@ -219,7 +236,7 @@ jobs:
set -euo pipefail
ARGS=(build --target "${{ matrix.target }}")
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
VERSION="${GITHUB_REF_NAME#v}"
VERSION="${RELEASE_TAG#v}"
NUMERIC_VERSION="${VERSION%%-*}"
NUMERIC_VERSION="${NUMERIC_VERSION%%+*}"
ARGS+=(--config "{\"bundle\":{\"windows\":{\"wix\":{\"version\":\"${NUMERIC_VERSION}\"}}}}")
@@ -244,6 +261,7 @@ jobs:
name: Upload desktop artifacts
runs-on: ubuntu-latest
needs: [changelog, desktop-build]
if: ${{ always() && needs.desktop-build.result == 'success' && (needs.changelog.result == 'success' || needs.changelog.result == 'skipped') }}
steps:
- name: Download desktop artifacts
uses: actions/download-artifact@v4
@@ -255,12 +273,23 @@ jobs:
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ env.RELEASE_TAG }}
run: |
set -euo pipefail
mapfile -t files < <(rg --files release-artifacts/desktop -g '*.AppImage' -g '*.app.tar.gz' -g '*.deb' -g '*.dmg' -g '*.exe' -g '*.msi' -g '*.rpm' -g '*.sig')
shopt -s nullglob globstar
files=(
release-artifacts/desktop/**/*.AppImage
release-artifacts/desktop/**/*.app.tar.gz
release-artifacts/desktop/**/*.deb
release-artifacts/desktop/**/*.dmg
release-artifacts/desktop/**/*.exe
release-artifacts/desktop/**/*.msi
release-artifacts/desktop/**/*.rpm
release-artifacts/desktop/**/*.sig
)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No desktop artifacts found" >&2
exit 1
fi
gh release upload "$TAG_NAME" "${files[@]}" --clobber
gh release upload "$TAG_NAME" "${files[@]}" --clobber --repo "$GH_REPO"