Skip to content

Commit d139b74

Browse files
committed
chore: add github action to release binary
1 parent 16cfb8b commit d139b74

7 files changed

Lines changed: 85 additions & 22 deletions

File tree

.gitflow.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**Features:**
2+
3+
**Fixes:**

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build Go
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "main"
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Set up go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: 1.19.2
22+
23+
- name: Build
24+
run: go build ./...
25+

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
if: contains(github.ref, 'refs/tags/')
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Set up go
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: 1.19.3
20+
21+
- name: Build
22+
run: bash hack/github-release.sh
23+
24+
- name: Create release
25+
uses: softprops/action-gh-release@v1
26+
with:
27+
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
28+
files: |
29+
out/*.zip
30+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
out
22
.vscode/
33
.idea/
4+
bin/

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ build-windows-amd64:
3434
.PHONY : build-all
3535
build-all: build-darwin-amd64 build-darwin-arm64 build-linux-arm64 build-linux-amd64 build-windows-amd64
3636

37-
.PHONY : release
38-
release:
39-
@gitflow run release -f .gitflow.yaml
40-
4137
.PHONY: fmt
4238
fmt:
4339
gofmt -w -s $(GOFMT_FILES)

hack/github-release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
targets=( \
6+
"darwin_amd64" \
7+
"darwin_arm64" \
8+
"linux_amd64" \
9+
"linux_arm64" \
10+
"windows_amd64" \
11+
"windows_arm64" \
12+
)
13+
14+
VERSION=${GITHUB_REF#refs/*/}
15+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
16+
17+
mkdir -p out
18+
19+
for target in "${targets[@]}"; do
20+
echo "Build target: ${target}"
21+
IFS='_' read -r -a tmp <<< "$target"
22+
BUILD_OS="${tmp[0]}"
23+
BUILD_ARCH="${tmp[1]}"
24+
GOOS="${BUILD_OS}" GOARCH="${BUILD_ARCH}" go build -mod=vendor -o bin/ucloud
25+
zip -r out/ucloud-${target}.zip ./bin LICENSE
26+
done

0 commit comments

Comments
 (0)