-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (107 loc) · 3.63 KB
/
release.yml
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Release
on:
push:
tags:
- "[0-9].[0-9]+.[0-9]+"
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.19
- name: Check github.ref
run: |
echo ${{ github.ref }}
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go get -v -t -d ./...
- name: Test code
run: go test -v ./...
setup-release:
name: Setup release
needs: test # This workflow is executed after completed 'test' job
runs-on: ubuntu-latest
steps:
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Get url to upload to release from output
env:
url: ${{ steps.create_release.outputs.upload_url }}
run: |
mkdir artifact
echo $url > artifact/url.txt
- name: Upload artifact to share url with other jobs
uses: actions/upload-artifact@v1
with:
name: artifact
path: artifact/url.txt
release-binary:
name: Release Binary
needs: setup-release
runs-on: ubuntu-latest
strategy:
matrix:
archtec: [linux_amd64, linux_arm64, windows_amd64]
include:
- archtec: linux_amd64
goos: linux
arch: amd64
- archtec: linux_arm64
goos: linux
arch: arm64
- archtec: windows_amd64
goos: windows
arch: amd64
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go get -v -t -d ./...
- name: Make package directory
run: |
mkdir ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}
cp README.md ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}/
cp config/device.json ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}/
- name: Add files for Windows
if: matrix.archtec == 'windows_amd64'
run: |
cp util/remane_file.bat ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}/
- name: Build
run: |
GCO_ENABLED=0 GOOS=${{matrix.goos}} GOARCH=${{matrix.arch}} go build -o ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}/${{ github.event.repository.name }} ./...
zip -r ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }} ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}
ls
- name: Download artifact to get url to upload to release
uses: actions/download-artifact@v1
with:
name: artifact
- name: Get url to upload to release from artifact
id: get_url
run: |
url=$(cat artifact/url.txt)
echo "##[set-output name=upload_url;]$url"
- name: Upload release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_url.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}.zip
asset_name: ${{ github.event.repository.name }}_${{ matrix.goos }}_${{ matrix.arch }}.zip
asset_content_type: application/octet-stream