Skip to content

Commit 9498e6d

Browse files
committed
Add GH action for automatic releases
1 parent 3231204 commit 9498e6d

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
jobs:
8+
9+
publish:
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest]
13+
go: [1.14]
14+
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- name: Set up Go ${{ matrix.go }}
18+
uses: actions/setup-go@v1
19+
with:
20+
go-version: ${{ matrix.go }}
21+
22+
- name: Set GOPATH, PATH and ENV
23+
run: |
24+
echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)"
25+
echo "::set-env name=GO111MODULE::on"
26+
echo "::set-env name=GOPROXY::https://proxy.golang.org"
27+
echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin"
28+
shell: bash
29+
30+
- name: Checkout Code
31+
uses: actions/checkout@v2
32+
33+
- name: Build
34+
run: ./make_release.sh
35+
36+
- name: Upload artifacts
37+
uses: svenstaro/upload-release-action@v1-release
38+
with:
39+
repo_token: ${{ secrets.GITHUB_TOKEN }}
40+
file: dist/*
41+
file_glob: true
42+
overwrite: true
43+
tag: ${{ github.ref }}

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ const (
2222
)
2323

2424
var (
25-
debugFlag = false
25+
debugFlag = false
26+
appVersion string
2627
)
2728

2829
func main() {
2930
app := cli.NewApp()
30-
app.Version = "0.5"
31+
app.Version = appVersion
3132
app.Usage = "tool for managing .mcm character sets for MAX7456"
3233
app.Flags = []cli.Flag{
3334
&cli.BoolFlag{

make_release.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
#!/bin/bash
2-
VERSION=$(grep app.Version main.go | cut -d= -f 2 | tr -d '[:space:]"')
2+
3+
set -e
4+
set -x
5+
6+
REV=$(git rev-parse --short HEAD)
7+
TAG=$(git describe --tags)
8+
VERSION="${TAG} (${REV})"
39
GO_OSARCH="darwin/amd64 linux/386 linux/amd64 linux/arm windows/386 windows/amd64"
410

511
mkdir -p dist
612

713
for v in ${GO_OSARCH}; do
814
GOOS=$(echo ${v} | cut -d/ -f 1)
915
GOARCH=$(echo ${v} | cut -d/ -f 2)
10-
GOOS=${GOOS} GOARCH=${GOARCH} go build
16+
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags "-X \"main.appVersion=${VERSION}\""
1117
exe=max7456tool
12-
rel=max7456tool_${VERSION}_${GOOS}_${GOARCH}
18+
rel=max7456tool_${TAG}_${GOOS}_${GOARCH}
1319
if [ ${GOOS} = "windows" ]; then
1420
exe=${exe}.exe
1521
zip=${rel}.zip
@@ -22,4 +28,4 @@ for v in ${GO_OSARCH}; do
2228
fi
2329
done
2430

25-
go clean
31+
go clean

0 commit comments

Comments
 (0)