forked from Bearer/bearer
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (139 loc) · 4.46 KB
/
canary.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
name: Canary
on:
workflow_dispatch:
permissions:
contents: write
packages: write
env:
GH_USER: "bearer-bot"
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
if: startsWith(github.ref, 'refs/tags') != true
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: v
default_bump: patch
append_to_pre_release_tag: "canary"
outputs:
ref: refs/tags/${{ steps.tag_version.outputs.new_tag || github.ref_name }}
build-linux:
needs: [tag]
name: build-linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.ref }}
- run: git fetch --force --tags
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- id: cache
uses: actions/cache@v3
with:
path: dist/linux
key: linux-${{ env.sha_short }}-canary
- uses: ./.github/actions/linux-build
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
name: Run GoReleaser
with:
args: release --clean --split -f ./.goreleaser/canary.yaml
env:
GOOS: linux
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
build-darwin:
needs: [tag]
name: build-darwin
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.ref }}
- run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Setup Gon
run: brew install Bearer/tap/gon
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v2
with:
# The certificates in a PKCS12 file encoded as a base64 string
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
# The password used to import the PKCS12 file.
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- id: cache
uses: actions/cache@v3
with:
path: dist/darwin
key: darwin-${{ env.sha_short }}-canary
- uses: goreleaser/goreleaser-action@v5
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
name: Run GoReleaser
with:
distribution: goreleaser-pro
version: latest
args: release --clean --split -f ./.goreleaser/canary.yaml
env:
GOOS: darwin
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
publish:
needs: [tag, build-darwin, build-linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.ref }}
- run:
git fetch --force --tags
# copy the cashes from prepare
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: dist/linux
key: linux-${{ env.sha_short }}-canary
- uses: actions/cache@v3
with:
path: dist/darwin
key: darwin-${{ env.sha_short }}-canary
- name: Release
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser-pro
args: publish --merge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: "docker.io/bearer/bearer:canary-amd64"
format: "table"
exit-code: 0
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL,HIGH"