-
Notifications
You must be signed in to change notification settings - Fork 7
275 lines (271 loc) · 11.1 KB
/
release.yml
File metadata and controls
275 lines (271 loc) · 11.1 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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Build and release sectionctl binaries
on:
push:
tags:
- 'v*' # Push events to matching v*, for example v1.0, v10.15.10
workflow_dispatch:
inputs:
publishRelease:
description: 'Create a new release with the artifacts'
required: false
default: 'false'
homebrew:
description: 'Make a PR for https://github.com/section/homebrew-brews'
required: false
default: 'false'
jobs:
release:
name: 🎬 Create the release
runs-on: ubuntu-latest
outputs:
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
build:
name: 🚧 Build binaries
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
GOOS: [linux, darwin, windows]
GOARCH: [amd64, arm64]
exclude:
- GOOS: windows
GOARCH: arm64
env:
VERSION: ${{ github.ref }}
GOARCH: ${{ matrix.GOARCH }}
GOOS: ${{ matrix.GOOS }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get Version
id: get_version
uses: battila7/get-version-action@v2
- run: echo "MAJORVERSION=${{ steps.get_version.outputs.major }}" >> $GITHUB_ENV
- run: echo "MINORVERSION=${{ steps.get_version.outputs.minor }}" >> $GITHUB_ENV
- run: echo "PATCHVERSION=${{ steps.get_version.outputs.patch }}" >> $GITHUB_ENV
- run: echo "VERSION=${{ steps.get_version.outputs.version }}" >> $GITHUB_ENV
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build
run: make build-release
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist/
- uses: actions/upload-artifact@v2
with:
name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.tar.gz
path: dist/sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_path: dist/sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.tar.gz
asset_name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.tar.gz
asset_content_type: application/gzip
build_linux_packages:
runs-on: 'ubuntu-latest'
needs: [build, release]
name: 🐧 Build Linux Packages (deb, rpm)
strategy:
matrix:
GOOS: [linux]
GOARCH: [amd64, arm64]
env:
VERSION: ${{ github.ref }}
GOARCH: ${{ matrix.GOARCH }}
GOOS: ${{ matrix.GOOS }}
DESC: 'Section command line tool.'
APP_NAME: 'sectionctl'
MAINTAINER: 'alice@section.io'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Download dist folder
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
- name: Get Version
id: get_version
uses: battila7/get-version-action@v2
- run: echo "MAJORVERSION=${{ steps.get_version.outputs.major }}" >> $GITHUB_ENV
- run: echo "MINORVERSION=${{ steps.get_version.outputs.minor }}" >> $GITHUB_ENV
- run: echo "PATCHVERSION=${{ steps.get_version.outputs.patch }}" >> $GITHUB_ENV
- run: echo "VER={{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}" >> $GITHUB_ENV
- run: echo "NO_V_VERSION=${{ steps.get_version.outputs.version-without-v }}" >> $GITHUB_ENV
- run: echo "VERSION=${{ steps.get_version.outputs.version }}" >> $GITHUB_ENV
- run: echo "ARCHSTRING=x86_64" >> $GITHUB_ENV
if: ${{ env.GOARCH == 'amd64' }}
- run: echo "ARCHSTRING=aarch64" >> $GITHUB_ENV
if: ${{ env.GOARCH != 'amd64' }}
- name: Copy binaries to deb package directory
run: |
cp -p dist/sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}/sectionctl .
chmod +x sectionctl
- uses: kentik/pkg@v1.0.0-rc7
with:
name: sectionctl
version: '${{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}'
arch: ${{env.ARCHSTRING}}
format: rpm
package: packaging/linux/package.yaml
- uses: kentik/pkg@v1.0.0-rc7
with:
name: sectionctl
version: '${{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}'
arch: ${{env.ARCHSTRING}}
format: deb
package: packaging/linux/package.yaml
- run: ls *.deb *.rpm
- uses: actions/upload-artifact@v2
with:
name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.deb
path: sectionctl_${{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}-1_${{ env.GOARCH }}.deb
- uses: actions/upload-artifact@v2
with:
name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.rpm
path: sectionctl-${{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}-1.${{ env.ARCHSTRING }}.rpm
- name: Add RPM to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.rpm
asset_path: sectionctl-${{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}-1.${{ env.ARCHSTRING }}.rpm
asset_content_type: application/octet-stream
- name: Add Deb to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}.deb
asset_path: sectionctl_${{env.MAJORVERSION}}.${{env.MINORVERSION}}.${{env.PATCHVERSION}}-1_${{ env.GOARCH }}.deb
asset_content_type: application/octet-stream
create_installer:
runs-on: 'windows-latest'
needs: [build, release]
name: 🪟 Create Windows Installer with NSIS
strategy:
matrix:
GOOS: [windows]
GOARCH: [amd64]
env:
VERSION: ${{ github.ref }}
GOARCH: ${{ matrix.GOARCH }}
GOOS: ${{ matrix.GOOS }}
DESC: 'Section command line tool.'
APP_NAME: 'sectionctl'
MAINTAINER: 'alice@section.io'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Download dist folder
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
- name: Get Version
id: get_version
uses: battila7/get-version-action@v2
- run: echo 'MAJORVERSION=${{ steps.get_version.outputs.major }}' >> $env:GITHUB_ENV
- run: echo 'MINORVERSION=${{ steps.get_version.outputs.minor }}' >> $env:GITHUB_ENV
- run: echo 'PATCHVERSION=${{ steps.get_version.outputs.patch }}' >> $env:GITHUB_ENV
- run: echo 'VERSION=${{ steps.get_version.outputs.version }}' >> $env:GITHUB_ENV
- run: echo $env:GITHUB_ENV
- name: Download EnVar plugin for NSIS
uses: carlosperate/download-file-action@v1.0.3
with:
file-url: https://nsis.sourceforge.io/mediawiki/images/7/7f/EnVar_plugin.zip
file-name: envar_plugin.zip
location: ${{ github.workspace }}
- name: Extract EnVar plugin
run: 7z x -o"${{ github.workspace }}/NSIS_Plugins" "${{ github.workspace }}/envar_plugin.zip"
- name: Create nsis installer
uses: joncloud/makensis-action@v3.3
with:
additional-plugin-paths: ${{ github.workspace }}/NSIS_Plugins/Plugins
arguments: >
-DARCH=amd64
-DOUTPUTFILE=sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}-installer.exe
-DSECTIONCTL_VERSION=${{ env.VERSION }}
-DMAJORVERSION=${{ env.MAJORVERSION }}
-DMINORVERSION=${{ env.MINORVERSION }}
-DBUILDVERSION=${{ env.PATCHVERSION }}
script-file: 'packaging/windows/nsis.sectionctl.nsi'
- name: Upload artifact
uses: actions/upload-artifact@v1.0.0
with:
name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}-installer.exe
path: packaging/windows/sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}-installer.exe
- name: Upload Installer Asset
id: upload-installer-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_path: packaging/windows/sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}-installer.exe
asset_name: sectionctl-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}-installer.exe
asset_content_type: application/octet-stream
delete_excess_artifacts:
runs-on: 'ubuntu-latest'
needs: [build, create_installer, build_linux_packages]
name: ❌ Delete unnecessary 100mb dist artifact
steps:
- uses: geekyeggo/delete-artifact@v1
with:
name: dist
homebrew:
name: 🍎 Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- name: Get Version
id: get_version
uses: battila7/get-version-action@v2
- run: echo 'MAJORVERSION=${{ steps.get_version.outputs.major }}' >> $env:GITHUB_ENV
- run: echo 'MINORVERSION=${{ steps.get_version.outputs.minor }}' >> $env:GITHUB_ENV
- run: echo 'PATCHVERSION=${{ steps.get_version.outputs.patch }}' >> $env:GITHUB_ENV
- run: echo 'VERSION=${{ steps.get_version.outputs.version }}' >> $env:GITHUB_ENV
- name: Extract version
id: extract-version
run: |
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
- uses: mislav/bump-homebrew-formula-action@v1
if: "!contains(github.ref, '-')" # skip prereleases
with:
formula-name: sectionctl
formula-path: Formula/sectionctl.rb
homebrew-tap: section/homebrew-brews
base-branch: main
download-url: https://github.com/section/sectionctl/archive/refs/tags/${{ steps.extract-version.outputs.tag-name }}.tar.gz
commit-message: |
{{formulaName}} ${{env.VERSION}}
Created by https://github.com/mislav/bump-homebrew-formula-action
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}