-
Notifications
You must be signed in to change notification settings - Fork 601
160 lines (140 loc) · 4.26 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
# Copyright 2020 Vectorized, 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]
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.16.3
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
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: build
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
arch: [amd64, arm64]
runs-on: macos-10.15
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 via HomeBrew for code signing and app notarization
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
- 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.json
- name: Upload signed Package
uses: actions/upload-artifact@v2
with:
name: rpk-archives
path: zip/rpk-darwin-${{ matrix.arch }}.zip
create-release:
name: Create release
needs: [build, sign-darwin]
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 }}
publish-release-artifacts:
name: Publish release
needs: create-release
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
arch: [amd64, arm64]
os: [linux, darwin]
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-${{ matrix.os }}-${{ matrix.arch }}.zip
asset_name: rpk-${{ matrix.os }}-${{ matrix.arch }}.zip
asset_content_type: application/zip