[英]How to use Go Release Binary GitHub Action
Anyone able to get Go Release Binary GitHub Action working?任何人都可以让Go 发布二进制 GitHub 动作正常工作吗? which is supposed to这应该是
Automate publishing Go build artifacts for GitHub releases through GitHub Actions通过 GitHub 操作自动发布 GitHub 版本的 Go 构建工件
The readme looks rather simple, but I've tried all my imaginations to get it working but not avail.自述文件看起来很简单,但我已经尝试了所有的想象力来让它工作但没有用。 Similar questions has been asked in its issue tracks but got no answer.在其问题跟踪中也提出了类似的问题,但没有得到答案。
Somebody help please.请有人帮忙。
BTW, while searching for the answer, I came upon this commit logs , which is quite interesting/amusing to read.顺便说一句,在寻找答案时,我发现了这个提交日志,读起来非常有趣/有趣。 Ie, it seems to be quite a battle to get it working, but the author gave up eventually (no any releases from his/her latest commits/tags)即,让它工作似乎是一场激烈的战斗,但作者最终放弃了(他/她最新的提交/标签中没有任何发布)
Conclusion:结论:
Turns out that my project does not have go mod
and there were issues in Go Release which stops it from working.事实证明,我的项目没有go mod
,并且 Go 版本中存在问题,导致它无法工作。 It was then fixed by this and this .然后由this和this修复。
I actually wrote my own release workflow for generating Go binaries.实际上,我编写了自己的发布工作流来生成 Go 二进制文件。
The only non-obvious steps from my point of view are:从我的角度来看,唯一不明显的步骤是:
The nice thing about softprops/action-gh-release
is that you can keep adding artifacts to the same release as long as the workflow run is triggered by a push to the same tag. softprops/action-gh-release
的好处在于,只要工作流运行是由推送到同一标签触发的,您就可以继续将工件添加到同一版本中。
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Latest Release
defaults:
run:
shell: bash
jobs:
lint:
name: Lint files
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.16.3'
- name: golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
with:
version: latest
test:
name: Run tests
runs-on: 'ubuntu-latest'
needs: lint
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.16.3'
- run: go test -v -cover
release:
name: Create Release
runs-on: 'ubuntu-latest'
needs: test
strategy:
matrix:
# List of GOOS and GOARCH pairs from `go tool dist list`
goosarch:
- 'aix/ppc64'
# etc
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: '1.16.3'
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=${{github.repository}}-$GOOS-$GOARCH
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Build
run: |
go build -o "$BINARY_NAME" -v
- name: Release Notes
run:
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
- name: Release with Notes
uses: softprops/action-gh-release@v1
with:
body_path: ".github/RELEASE-TEMPLATE.md"
draft: true
files: ${{env.BINARY_NAME}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.