Skip to content

Commit

Permalink
chore: 使用 Actions 自动打包发布
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoux committed May 26, 2023
1 parent 57a21ca commit ed5106f
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build
on:
push

jobs:
gen-new-release-item:
if: startsWith(github.ref, 'refs/tags/') #在打tag时候触发
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: gen changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

- name: Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ngapost2md ver.[NEO_${{ github.ref }}]
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false

release-matrix:
needs: gen-new-release-item
if: startsWith(github.ref, 'refs/tags/') #在打tag时候触发
name: release binary
env:
commitmsg: ${{ github.event.head_commit.message }}
runs-on: ubuntu-latest

strategy:
matrix:
goos: [linux, windows, darwin]
goarch: ["386",amd64, arm64]
exclude:
- goarch: arm64
goos: windows
- goarch: "386"
goos: windows
- goarch: "386"
goos: darwin
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get tag
id: tag
uses: devops-actions/[email protected]
with:
strip_v: true # Optional: Remove 'v' character from version
default: v0.0.0 # Optional: Default version when tag not found

- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_tag: ${{steps.tag.outputs.tag}}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
md5sum: FALSE
extra_files: LICENSE README.md assets/* #将这些文件一并打包
ldflags: -X github.com/ludoux/ngapost2md/nga.DEBUG_MODE=0
overwrite: TRUE #若已有附件则覆写

1 comment on commit ed5106f

@ludoux
Copy link
Owner Author

@ludoux ludoux commented on ed5106f May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要打包时,对指定 commit 附加 tag (如1.0.1)并push到远端,即可触发此 GitHub Actions。此GitHub Actions 会自动发布新的 Releases 条目和附件。需要注意 nga.go 内的 VERSION是需要手动修改的。

Please sign in to comment.