Skip to content

Commit 5ba64c5

Browse files
committed
Add new Release Workflow using Github Actions and wangyoucao577/go-release-action
1 parent 7f34fcb commit 5ba64c5

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

.github/workflows/release.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Go Binaries
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
releases-matrix:
9+
name: Release Go Binary
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
goos: [freebsd, linux, windows]
14+
goarch: ["386", amd64]
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Set APP_VERSION env
19+
run: echo APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
20+
- name: Set BUILD_TIME env
21+
run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV}
22+
23+
- uses: wangyoucao577/[email protected]
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
goos: ${{ matrix.goos }}
27+
goarch: ${{ matrix.goarch }}
28+
goversion: "https://golang.org/dl/go1.15.8.linux-amd64.tar.gz"
29+
extra_files: LICENSE README.md smtprelay.ini
30+
ldflags: -s -w -X "main.appVersion=${{ env.APP_VERSION }}" -X "main.buildTime=${{ env.BUILD_TIME }}"

config.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import (
66
"github.com/vharitonsky/iniflags"
77
)
88

9-
const (
10-
VERSION = "1.4.0"
9+
var (
10+
appVersion = "unknown"
11+
buildTime = "unknown"
1112
)
1213

1314
var (

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func main() {
234234
ConfigLoad()
235235

236236
if *versionInfo {
237-
fmt.Printf("smtprelay/%s\n", VERSION)
237+
fmt.Printf("smtprelay/%s (%s)\n", appVersion, buildTime)
238238
os.Exit(0)
239239
}
240240

scripts/release.sh

-34
This file was deleted.

0 commit comments

Comments
 (0)