-
Notifications
You must be signed in to change notification settings - Fork 9
173 lines (146 loc) · 4.45 KB
/
create-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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Create Release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
name: Build & Upload
strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
arch: [amd64, arm64]
include:
- os: ubuntu-20.04
target: "./cmd/longtail/longtail"
platform: linux
tag: "${GITHUB_REF_NAME}"
- os: macos-latest
target: "./cmd/longtail/longtail"
platform: macos
tag: "${GITHUB_REF_NAME}"
- os: windows-latest
target: "./cmd/longtail/longtail.exe"
platform: win32
tag: "${env:GITHUB_REF_NAME}"
exclude:
- os: ubuntu-20.04
arch: arm64
- os: windows-latest
arch: arm64
runs-on: ${{matrix.os}}
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Check out source code
uses: actions/checkout@v3
- name: Build
run: |
echo "GOARCH: " $GOARCH
pushd ./cmd/longtail
echo matrix.tag ${{ matrix.tag }}
go build -ldflags="-s -w -X 'github.com/DanEngelbrecht/golongtail/commands.BuildVersion=${{ matrix.tag }}'" .
popd
env:
GOARCH: ${{matrix.arch}}
CGO_ENABLED: 1
- name: build dist
run: |
mkdir dist
cp ${{matrix.target}} dist/
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: dist-${{matrix.platform}}-${{matrix.arch}}
path: dist
create-release:
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Linux artifacts
uses: actions/download-artifact@v1
with:
name: dist-linux-amd64
path: dist-linux-amd64
- name: Download MacOs x64 artifacts
uses: actions/download-artifact@v1
with:
name: dist-macos-amd64
path: dist-macos-amd64
- name: Download MacOs arm64 artifacts
uses: actions/download-artifact@v1
with:
name: dist-macos-arm64
path: dist-macos-arm64
- name: Download Win32 artifacts
uses: actions/download-artifact@v1
with:
name: dist-win32-amd64
path: dist-win32-amd64
- name: Rename artifacts
run: |
cp dist-linux-amd64/longtail longtail-linux-x64
cp dist-macos-amd64/longtail longtail-macos-x64
cp dist-macos-arm64/longtail longtail-macos-arm64
cp dist-win32-amd64/longtail.exe longtail-win32-x64.exe
- name: Set execute permission
run: |
chmod +x longtail-linux-x64
chmod +x longtail-macos-x64
chmod +x longtail-macos-arm64
- name: Zip Linux artifacts
uses: montudor/[email protected]
with:
args: zip -qq -r ./linux-x64.zip ./dist-linux-x64
- name: Zip MacOS x64 artifacts
uses: montudor/[email protected]
with:
args: zip -qq -r ./macos-x64.zip ./dist-macos-x64
- name: Zip MacOS arm64 artifacts
uses: montudor/[email protected]
with:
args: zip -qq -r ./macos-arm64.zip ./dist-macos-arm64
- name: Zip Win32 artifacts
uses: montudor/[email protected]
with:
args: zip -qq -r ./win32-x64.zip ./dist-win32-x64
- name: Check prerelease
id: get-prerelease
uses: haya14busa/action-cond@v1
with:
cond: ${{contains(github.ref, '-pre')}}
if_true: "true"
if_false: "false"
- name: Extract Version Changes
run: |
sed '1,/^##/!d;/##/d' CHANGELOG.md > CHANGELOG.tmp
- name: Read CHANGELOG.tmp
id: read_changelog
uses: andstor/file-reader-action@v1
with:
path: "CHANGELOG.tmp"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{github.ref.name}}
body: |
${{steps.read_changelog.outputs.contents}}
draft: false
prerelease: ${{steps.get-prerelease.outputs.value}}
files: |
win32-x64.zip
linux-x64.zip
macos-x64.zip
macos-arm64.zip
longtail-linux-x64
longtail-macos-x64
longtail-macos-arm64
longtail-win32-x64.exe