Update composeImage.yml #15
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
name: 构建 Go 二进制文件 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 检出仓库 | ||
uses: actions/checkout@v4 | ||
- name: 缓存 Go 模块 | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: 设置 Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- name: 编译二进制文件 | ||
run: | | ||
go build -v -o composeImage ./... | ||
- name: 创建 Release | ||
if: github.event_name == 'release' | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref_name }} | ||
release_name: Release ${{ github.ref_name }} | ||
draft: false | ||
prerelease: false | ||
- name: 上传编译文件到 Release | ||
if: github.event_name == 'release' | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: bin/composeImage.zip | ||
asset_name: composeImage.zip | ||
asset_content_type: application/zip |