From afbbe854a28fe1bef7690d0147d850719d53c018 Mon Sep 17 00:00:00 2001 From: PEMessage <1165739182@qq.com> Date: Wed, 2 Sep 2026 00:28:09 +0800 Subject: [PATCH] feat(ci): release binary --- .github/workflows/release.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 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..50ff8de --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: release + +on: + push: + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + strategy: + fail-fast: false + matrix: + goos: [linux, darwin, windows] + goarch: [amd64, arm64] + exclude: + - goos: windows + goarch: arm64 + + runs-on: ubuntu-latest + env: + CGO_ENABLED: "0" + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Build + run: | + goos="${{ matrix.goos }}" + goarch="${{ matrix.goarch }}" + out="sol-${goos}-${goarch}" + [ "${goos}" = "windows" ] && out="${out}.exe" + go build -trimpath -ldflags "-s -w" -o "${out}" ./cmd/sol + echo "ARTIFACT=${out}" >> "${GITHUB_ENV}" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT }} + path: ${{ env.ARTIFACT }} + if-no-files-found: error + + release: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - name: Tagged release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: dist/* + + - name: Nightly prerelease + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + uses: softprops/action-gh-release@v2 + with: + files: dist/* + name: nightly + tag_name: nightly + prerelease: true