From 4298611c2c786e075ea18985789b271a574cffef Mon Sep 17 00:00:00 2001 From: liyp Date: Fri, 23 Oct 2026 13:03:19 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=89=93=20v*=20tag=20=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=9E=84=E5=BB=BA=E5=85=AD=E5=B9=B3=E5=8F=B0=E4=BA=8C?= =?UTF-8?q?=E8=BF=9B=E5=88=B6=E5=B9=B6=E6=8C=82=E5=88=B0=20GitHub=20Releas?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test job 先跑 golink (38) 与 goscp (19) 两套端到端测试 - release job 用 build.sh 交叉编译,校验版本号与 SHA256SUMS - gh release create/upload 推送 13 个附件,支持 workflow_dispatch 重建 --- .github/workflows/release.yml | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9b237c2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +name: Release + +# A pushed v* tag makes this workflow build every desktop target, run the +# end-to-end suites and attach the binaries to the matching GitHub release. +# workflow_dispatch lets an existing tag be rebuilt without moving it. + +on: + push: + tags: + - "v*" + workflow_dispatch: + inputs: + tag: + description: "Tag to build and publish (for example v1.0.1)" + required: true + type: string + +permissions: + contents: write + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + test: + name: End-to-end tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: golink suite + run: ./smoketest/run.sh + + - name: goscp suite + run: ./smoketest/run-goscp.sh + + release: + name: Build and publish + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Resolve tag + id: tag + env: + DISPATCH_TAG: ${{ inputs.tag }} + PUSHED_TAG: ${{ github.ref_name }} + run: | + set -euo pipefail + tag="${DISPATCH_TAG:-$PUSHED_TAG}" + echo "value=$tag" >> "$GITHUB_OUTPUT" + echo "building $tag" + + - name: Build every target + env: + TAG: ${{ steps.tag.outputs.value }} + run: | + set -euo pipefail + VERSION="${TAG#v}" ./build.sh + + - name: Verify the binaries + env: + TAG: ${{ steps.tag.outputs.value }} + run: | + set -euo pipefail + want="${TAG#v}" + for program in golink goscp; do + got="$(./dist/$program -version | awk '{print $2}')" + echo "$program: $got" + [ "$got" = "$want" ] || { echo "version mismatch: want $want, got $got" >&2; exit 1; } + done + sha256sum -c dist/SHA256SUMS + + - name: Publish to the release + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.tag.outputs.value }} + run: | + set -euo pipefail + if gh release view "$TAG" >/dev/null 2>&1; then + echo "release $TAG already exists, replacing assets" + else + gh release create "$TAG" \ + --title "sshtools $TAG" \ + --generate-notes \ + --verify-tag + fi + gh release upload "$TAG" dist/golink_* dist/goscp_* dist/SHA256SUMS --clobber + gh release view "$TAG"