Skip to content

Commit

Permalink
add release
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Sep 15, 2022
1 parent 910de90 commit 2f6f2d1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 49 deletions.
58 changes: 9 additions & 49 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
- 1.19
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go_version }}

Expand All @@ -32,54 +33,13 @@ jobs:
restore-keys: |
${{ runner.os }}-golang-
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v2
with:
go-version: ${{ matrix.go_version }}

- name: Mod download
run: go mod download

- run: |
mkdir -p build
- name: Build with xgo
uses: TianTianBigWang/ghaction-xgo@master
with:
xgo_version: v0.1
go_version: ${{ matrix.go_version }}
pkg: cmd/ylgy
dest: build
prefix: ylgy
targets: windows/amd64,linux/arm64,linux/amd64,darwin/arm64,darwin/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default

- name: Move
run: |
ls ./build
mkdir -p release
mv $GITHUB_WORKSPACE/build/ylgy-darwin-10.16-amd64 release/ylgy_darwin_amd64 && chmod +x release/ylgy_darwin_amd64
mv $GITHUB_WORKSPACE/build/ylgy-darwin-10.16-arm64 release/ylgy_darwin_arm64 && chmod +x release/ylgy_darwin_arm64
mv $GITHUB_WORKSPACE/build/ylgy-linux-amd64 release/ylgy_linux_amd64 && chmod +x release/ylgy_linux_amd64
mv $GITHUB_WORKSPACE/build/ylgy-windows-4.0-amd64.exe release/ylgy_windows_amd64.exe
cd release
tar -zcvf ylgy_darwin_amd64.tar.gz ylgy_darwin_amd64
tar -zcvf ylgy_darwin_arm64.tar.gz ylgy_darwin_arm64
tar -zcvf ylgy_linux_amd64.tar.gz ylgy_linux_amd64
zip -q -r ylgy_windows_amd64.zip ylgy_windows_amd64.exe
- name: Release
uses: softprops/action-gh-release@v1
- name: GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
files: |
release/ylgy_linux_amd64.tar.gz
release/ylgy_windows_amd64.zip
release/ylgy_darwin_amd64.tar.gz
release/ylgy_darwin_arm64.tar.gz
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-release:
runs-on: ubuntu-latest
Expand Down
42 changes: 42 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
before:
hooks:
- go mod tidy

gomod:
proxy: true
env:
- GOPROXY=https://goproxy.cn,https://goroxy.io,https://proxy.golang.org,direct
- GOSUMDB=sum.golang.org
mod: mod

builds:
- main: cmd/ylgy
env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
goarch:
- amd64
- '386'
- arm64
- arm
goarm:
- '6'
- '7'
ignore:
- goos: windows
goarm: '6'

archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'

0 comments on commit 2f6f2d1

Please sign in to comment.