-
Notifications
You must be signed in to change notification settings - Fork 6
178 lines (178 loc) · 6.48 KB
/
test-and-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
174
175
176
177
178
name: "Test & Release"
on:
push:
branches:
- '*'
release:
types:
- created
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.20
uses: actions/setup-go@v5
with:
go-version: '^1.20'
id: go
- name: Run tests
run: go test -coverprofile c.out ./...
- name: Produce coverage report
run: go tool cover -html=c.out -o coverage.html
- name: Save coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}
path: coverage.html
build-linux:
if: ${{ github.event_name == 'release' }}
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.20
uses: actions/setup-go@v5
with:
go-version: '^1.20'
- name: Build on Linux
working-directory: ${{ github.workspace }}/cmd/transitland
run: CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.tag=$(git describe --tags --abbrev=0)"
- name: Store Linux binary
uses: actions/upload-artifact@v4
with:
name: transitland-linux
path: ${{ github.workspace }}/cmd/transitland/transitland
build-macos-intel:
if: ${{ github.event_name == 'release' }}
needs: test
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.20
uses: actions/setup-go@v5
with:
go-version: '^1.20'
- name: Build on macOS
working-directory: ${{ github.workspace }}/cmd/transitland
run: CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.tag=$(git describe --tags --abbrev=0)"
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v2
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 install Bearer/tap/gon
- name: Sign the mac binaries with Gon
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
run: |
gon -log-level=debug -log-json ./.github/gonconfig.json
- name: Store macOS binary
uses: actions/upload-artifact@v4
with:
name: transitland-macos-intel
path: ${{ github.workspace }}/transitland.zip
build-macos-apple:
if: ${{ github.event_name == 'release' }}
needs: test
runs-on: macos-latest-xlarge # to use Apple Silicon: https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.20
uses: actions/setup-go@v5
with:
go-version: '^1.20'
- name: Build on macOS
working-directory: ${{ github.workspace }}/cmd/transitland
run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.tag=$(git describe --tags --abbrev=0)"
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v2
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 install Bearer/tap/gon
- name: Sign the mac binaries with Gon
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
run: |
gon -log-level=debug -log-json ./.github/gonconfig.json
- name: Store macOS binary
uses: actions/upload-artifact@v4
with:
name: transitland-macos-apple
path: ${{ github.workspace }}/transitland.zip
release:
if: ${{ github.event_name == 'release' }}
needs: [build-linux, build-macos-intel, build-macos-apple]
runs-on: ubuntu-latest
steps:
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: transitland-linux
path: transitland-linux
- name: Attach Linux binary to GitHub release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ github.workspace }}/transitland-linux/transitland
asset_name: transitland-linux
asset_content_type: application/binary
- name: Download macOS Intel binary
uses: actions/download-artifact@v4
with:
name: transitland-macos-intel
path: transitland-macos-intel
- name: Attach macOS Intel binary to GitHub release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ github.workspace }}/transitland-macos-intel/transitland.zip
asset_name: transitland-macos-intel.zip
asset_content_type: application/binary
- name: Download macOS Apple Silicon binary
uses: actions/download-artifact@v4
with:
name: transitland-macos-apple
path: transitland-macos-apple
- name: Attach macOS Apple Silicon binary to GitHub release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ github.workspace }}/transitland-macos-apple/transitland.zip
asset_name: transitland-macos-apple.zip
asset_content_type: application/binary
release-notes:
needs: release
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- run: npm install github-release-notes -g
- run: gren release --override
env:
GREN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}