-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5474ef0
commit c6147de
Showing
3 changed files
with
115 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,55 @@ | ||
name: 最新版 | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
BINARY_PREFIX: "zbp_" | ||
BINARY_SUFFIX: "" | ||
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request." | ||
LD_FLAGS: "-w -s" | ||
|
||
jobs: | ||
build: | ||
name: Build binary CI | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 | ||
goos: [linux, windows] | ||
goarch: ["386", amd64, arm, arm64] | ||
exclude: | ||
- goos: windows | ||
goarch: arm | ||
- goos: windows | ||
goarch: arm64 | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup Go environment | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: '1.20' | ||
- name: Cache downloaded module | ||
uses: actions/cache@master | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }} | ||
- name: Build binary file | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
IS_PR: ${{ !!github.head_ref }} | ||
run: | | ||
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi | ||
if $IS_PR ; then echo $PR_PROMPT; fi | ||
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX" | ||
export CGO_ENABLED=0 | ||
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" . | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@master | ||
if: ${{ !github.head_ref }} | ||
with: | ||
name: ${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: output/ |
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,33 @@ | ||
name: PushLint | ||
on: [ push ] | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@master | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@master | ||
with: | ||
version: latest | ||
|
||
- name: Commit back | ||
if: ${{ !github.head_ref }} | ||
continue-on-error: true | ||
run: | | ||
git config --local user.name 'github-actions[bot]' | ||
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
git add --all | ||
git commit -m "🎨 改进代码样式" | ||
- name: Create Pull Request | ||
if: ${{ !github.head_ref }} | ||
continue-on-error: true | ||
uses: peter-evans/create-pull-request@v4 |
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,27 @@ | ||
name: 发行版 | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@master | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |