Skip to content

Release Coss Cli

Release Coss Cli #7

Workflow file for this run

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
# 输出构建好的文件
ls build/${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}*
env:
GO: go
VERSION: ${{ github.ref_name }}
- name: Create Release
id: create_release
if: ${{ matrix.platform == 'linux' && matrix.arch == 'amd64' }} # 只在一个平台上创建发布,以避免重复创建
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body: Release version ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}*
asset_name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}
asset_content_type: application/octet-stream