-
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.
- Loading branch information
Showing
1 changed file
with
65 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,65 @@ | ||
name: Release Coss Cli | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' # 只在 tag push 时触发工作流 | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
platform: [ linux, windows, darwin ] | ||
arch: [ amd64 ] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.22 | ||
|
||
- name: Set environment variables | ||
run: | | ||
echo "GOOS=${{ matrix.platform }}" >> $GITHUB_ENV | ||
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV | ||
if [ "${{ matrix.platform }}" = "windows" ]; then | ||
echo "EXT=.exe" >> $GITHUB_ENV | ||
else | ||
echo "EXT=" >> $GITHUB_ENV | ||
fi | ||
- name: Build | ||
run: make build | ||
env: | ||
GO: go | ||
VERSION: ${{ github.ref_name }} | ||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.platform }}-${{ matrix.arch }}-build | ||
path: build/*-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}* | ||
|
||
create-release: | ||
needs: build-and-release | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download Build Artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ matrix.platform }}-${{ matrix.arch }}-build | ||
path: build | ||
|
||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
TAG=${GITHUB_REF/refs\/tags\//} | ||
gh release create "$TAG" build/* --title "$TAG" --notes "Release version $TAG" |