-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (86 loc) · 2.74 KB
/
Copy pathrelease.yml
File metadata and controls
90 lines (86 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
release:
name: Create Github Release
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt
build:
name: Build
needs: [release]
strategy:
matrix:
go-os: [linux, windows]
go-arch: [386, amd64, arm, arm64]
exclude:
- go-os: windows
go-arch: arm64
runs-on: ubuntu-latest
steps:
- name: Load Release URL File from release job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Get Release Upload URL
id: get_release_info
run: |
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
id: binary_build
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.go-os }}
GOARCH: ${{ matrix.go-arch }}
run: |
BINARY=mqtt-executor-${{ matrix.go-os }}-${{ matrix.go-arch }}
if [ "$GOOS" = "windows" ]; then
BINARY=$BINARY.exe
fi
go build -a -installsuffix cgo -o $BINARY -v ./cmd/mqtt-executor/
#transfer BINARY env variable to following steps
echo "::set-output name=binary_name::$BINARY"
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./${{ steps.binary_build.outputs.binary_name }}
asset_name: ${{ steps.binary_build.outputs.binary_name }}
asset_content_type: application/octet-stream