-
Notifications
You must be signed in to change notification settings - Fork 601
185 lines (163 loc) · 5.13 KB
/
rpk-build.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
174
175
176
177
178
179
180
181
182
183
184
185
# Copyright 2020 Redpanda Data, Inc.
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.md
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0
name: Go
on:
push:
tags:
- 'v2**'
branches:
- '*'
pull_request:
branches:
- main
- dev
jobs:
build:
name: Test and Build
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.8
id: go
- name: Set up Node
uses: actions/setup-node@v2-beta
with:
node-version: '12.16.1'
- name: Test
working-directory: src/go/rpk/
run: go test -v ./...
- name: Build
working-directory: src/go/rpk/
run: |
pkg='vectorized/pkg/cli/cmd/version'
tag=$(echo ${{ github.ref }} | sed 's;refs/tags/;;g')
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} ./build.sh $tag ${{ github.sha }}
- name: Package
if: ${{ matrix.os != 'windows'}}
working-directory: src/go/rpk/
run: |
zip -j rpk-${{ matrix.os }}-${{ matrix.arch }}.zip ./${{ matrix.os }}-${{ matrix.arch }}/rpk
- name: Upload build artifacts
uses: actions/upload-artifact@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
name: rpk-archives
path: |
src/go/rpk/rpk-*.zip
sign-darwin:
name: Sign and notarize the darwin release_name
needs: create-release
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
arch: [amd64, arm64]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download zip
uses: actions/download-artifact@v2
with:
name: rpk-archives
path: zip/
- name: Unzip darwin build
working-directory: zip/
run: |
unzip rpk-darwin-${{ matrix.arch }}.zip
rm rpk-darwin-${{ matrix.arch }}.zip
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
- name: Install gon for code signing and app notarization
run: |
curl -LO https://github.com/mitchellh/gon/releases/download/v0.2.5/gon_macos.zip
unzip gon_macos.zip
rm gon_macos.zip
- name: Sign the mac binaries with Gon
working-directory: zip/
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
run: |
../gon -log-level=info ../src/go/rpk/gon_${{ matrix.arch }}.json
- name: Upload signed Package
uses: actions/upload-artifact@v2
with:
name: rpk-archives
path: zip/rpk-darwin-${{ matrix.arch }}.zip
outputs:
upload_url: ${{ needs.create-release.outputs.upload_url }}
create-release:
name: Create release
needs: [build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Create rpk release
id: create_rpk_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
outputs:
upload_url: ${{ steps.create_rpk_release.outputs.upload_url }}
upload-release-artifacts-linux:
name: Upload linux binaries
needs: [create-release]
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- name: Download compressed rpk artifacts
uses: actions/download-artifact@v2
- name: Upload rpk artifacts to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: rpk-archives/rpk-linux-${{ matrix.arch }}.zip
asset_name: rpk-linux-${{ matrix.arch }}.zip
asset_content_type: application/zip
upload-release-artifacts-darwin:
name: Upload darwin binaries
needs: [sign-darwin]
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- name: Download compressed rpk artifacts
uses: actions/download-artifact@v2
- name: Upload rpk artifacts to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.sign-darwin.outputs.upload_url }}
asset_path: rpk-archives/rpk-darwin-${{ matrix.arch }}.zip
asset_name: rpk-darwin-${{ matrix.arch }}.zip
asset_content_type: application/zip