-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(release): 添加 GitHub Actions 构建和发布工作流
- Loading branch information
1 parent
19fb21a
commit 545043f
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build and release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
goos: [ windows ] | ||
goarch: [ amd64, arm64 ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Get short commit SHA | ||
id: commit-sha | ||
run: echo "COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Build for ${{ matrix.goos }}/${{ matrix.goarch }} | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
CGO_ENABLED: 0 | ||
LDFLAGS: '-s -w -X main.build=${{ env.COMMIT_SHA_SHORT }} -H=windowsgui' | ||
run: | | ||
mkdir -p bin | ||
go version | ||
go build -ldflags="$LDFLAGS" -trimpath -o bin/gohomo-${{ matrix.goos }}-${{ matrix.goarch }}-${{ env.COMMIT_SHA_SHORT }}.exe . | ||
echo "${{ env.COMMIT_SHA_SHORT }}" > bin/version.txt | ||
- name: Upload release assets | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: bin/* | ||
make_latest: true |