Skip to content

Commit be842a0

Browse files
committed
chore: split release workflow so the majority happens on Linux
1 parent ab8235f commit be842a0

File tree

5 files changed

+278
-112
lines changed

5 files changed

+278
-112
lines changed

.github/workflows/coder.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ jobs:
226226
token: ${{ secrets.CODECOV_TOKEN }}
227227
files: ./gotests.coverage
228228
flags: unittest-go-${{ matrix.os }}
229-
# this flakes and sometimes fails the build
229+
# this flakes and sometimes fails the build
230230
fail_ci_if_error: false
231231

232232
test-go-postgres:
@@ -310,14 +310,16 @@ jobs:
310310
token: ${{ secrets.CODECOV_TOKEN }}
311311
files: ./gotests.coverage
312312
flags: unittest-go-postgres-${{ matrix.os }}
313-
# this flakes and sometimes fails the build
313+
# this flakes and sometimes fails the build
314314
fail_ci_if_error: false
315315

316316
deploy:
317317
name: "deploy"
318318
runs-on: ubuntu-latest
319319
timeout-minutes: 20
320320
if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
321+
needs:
322+
- test-go-postgres
321323
permissions:
322324
contents: read
323325
id-token: write
@@ -437,7 +439,7 @@ jobs:
437439
token: ${{ secrets.CODECOV_TOKEN }}
438440
files: ./site/coverage/lcov.info
439441
flags: unittest-js
440-
# this flakes and sometimes fails the build
442+
# this flakes and sometimes fails the build
441443
fail_ci_if_error: false
442444

443445
- name: Upload DataDog Trace

.github/workflows/release.yaml

Lines changed: 131 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,82 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
goreleaser:
10-
runs-on: macos-latest
11-
env:
12-
# Necessary for Docker manifest
13-
DOCKER_CLI_EXPERIMENTAL: "enabled"
9+
linux-windows:
10+
runs-on: ubuntu-latest
1411
steps:
15-
# Docker is not included on macos-latest
16-
- uses: docker-practice/actions-setup-docker@1.0.10
17-
1812
- uses: actions/checkout@v3
1913
with:
2014
fetch-depth: 0
2115

22-
- name: Set up QEMU
23-
uses: docker/setup-qemu-action@v2
16+
- uses: actions/setup-go@v3
17+
with:
18+
go-version: "~1.18"
2419

25-
- name: Docker Login
26-
uses: docker/login-action@v2
20+
- name: Echo Go Cache Paths
21+
id: go-cache-paths
22+
run: |
23+
echo "::set-output name=go-build::$(go env GOCACHE)"
24+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
25+
26+
- name: Go Build Cache
27+
uses: actions/cache@v3
2728
with:
28-
registry: ghcr.io
29-
username: ${{ github.repository_owner }}
30-
password: ${{ secrets.GITHUB_TOKEN }}
29+
path: ${{ steps.go-cache-paths.outputs.go-build }}
30+
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
31+
32+
- name: Go Mod Cache
33+
uses: actions/cache@v3
34+
with:
35+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
36+
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
37+
38+
- name: Cache Node
39+
id: cache-node
40+
uses: actions/cache@v3
41+
with:
42+
path: |
43+
**/node_modules
44+
.eslintcache
45+
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
46+
restore-keys: |
47+
js-${{ runner.os }}-
48+
49+
- name: Build Site
50+
run: make site/out/index.html
51+
52+
- name: Build Linux binaries with GoReleaser
53+
uses: goreleaser/goreleaser-action@v3
54+
with:
55+
version: latest
56+
args: build --rm-dist --timeout 60m --id coder-linux
57+
58+
- name: Build Windows binaries with GoReleaser
59+
uses: goreleaser/goreleaser-action@v3
60+
with:
61+
version: latest
62+
args: build --rm-dist --timeout 60m --id coder-windows
63+
64+
- name: Upload Linux binary artifacts
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: linux
68+
path: ./dist/coder-linux-*
69+
70+
- name: Upload Windows binary artifacts
71+
uses: actions/upload-artifact@v3
72+
with:
73+
name: windows
74+
path: ./dist/coder-windows-*
75+
76+
# The mac binaries get built on mac runners because they need to be signed,
77+
# and the signing tool only runs on mac. This darwin job only builds the Mac
78+
# binaries and uploads them as job artifacts used by the publish step.
79+
darwin:
80+
runs-on: macos-latest
81+
steps:
82+
- uses: actions/checkout@v3
83+
with:
84+
fetch-depth: 0
3185

3286
- uses: actions/setup-go@v3
3387
with:
@@ -79,12 +133,72 @@ jobs:
79133
- name: Build Site
80134
run: make site/out/index.html
81135

82-
- name: Run GoReleaser
136+
- name: Build darwin binaries with GoReleaser
137+
uses: goreleaser/goreleaser-action@v3
138+
with:
139+
version: latest
140+
args: build --rm-dist --timeout 60m --id coder-darwin
141+
env:
142+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
143+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
144+
145+
- name: Upload binary artifacts
146+
uses: actions/upload-artifact@v3
147+
with:
148+
name: darwin
149+
path: ./dist/coder-darwin-*
150+
151+
publish:
152+
runs-on: ubuntu-latest
153+
needs:
154+
- linux-windows
155+
- darwin
156+
env:
157+
# Necessary for Docker manifest
158+
DOCKER_CLI_EXPERIMENTAL: "enabled"
159+
steps:
160+
- uses: actions/checkout@v3
161+
with:
162+
fetch-depth: 0
163+
164+
- name: Docker Login
165+
uses: docker/login-action@v2
166+
with:
167+
registry: ghcr.io
168+
username: ${{ github.repository_owner }}
169+
password: ${{ secrets.GITHUB_TOKEN }}
170+
171+
- name: mkdir artifacts
172+
run: mkdir artifacts
173+
174+
- name: Download Linux artifacts
175+
uses: actions/download-artifact@v3
176+
with:
177+
name: linux
178+
path: ./artifacts
179+
180+
- name: Download Windows artifacts
181+
uses: actions/download-artifact@v3
182+
with:
183+
name: windows
184+
path: ./artifacts
185+
186+
- name: Download darwin artifacts
187+
uses: actions/download-artifact@v3
188+
with:
189+
name: darwin
190+
path: ./artifacts
191+
192+
# This will build Docker images and Linux packages.
193+
- name: Publish release
83194
uses: goreleaser/goreleaser-action@v3
84195
with:
196+
# we use the "prebuilt" builder here which is a pro-only feature
197+
distribution: goreleaser-pro
85198
version: latest
86-
args: release --rm-dist --timeout 60m
199+
args: release -f ./.goreleaser-release.yaml --rm-dist --timeout 60m
87200
env:
201+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
88202
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89203
AC_USERNAME: ${{ secrets.AC_USERNAME }}
90204
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}

.goreleaser-release.yaml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
archives:
2+
- id: coder-linux
3+
builds: [release-prebuilt-linux]
4+
format: tar.gz
5+
6+
- id: coder-windows
7+
builds: [release-prebuilt-windows]
8+
format: zip
9+
10+
- id: coder-darwin
11+
builds: [release-prebuilt-darwin]
12+
format: zip
13+
14+
builds:
15+
- id: release-prebuilt-linux
16+
builder: prebuilt
17+
goos: [linux]
18+
goarch: [amd64, arm, arm64]
19+
goarm: ["7"]
20+
prebuilt:
21+
path: artifacts/coder-linux_{{.Os}}_{{.Arch}}/coder
22+
23+
- id: release-prebuilt-windows
24+
builder: prebuilt
25+
goos: [windows]
26+
goarch: [amd64, arm64]
27+
prebuilt:
28+
path: artifacts/coder-windows_{{.Os}}_{{.Arch}}/coder.exe
29+
30+
- id: release-prebuilt-darwin
31+
builder: prebuilt
32+
goos: [darwin]
33+
goarch: [amd64, arm64]
34+
prebuilt:
35+
path: artifacts/coder-darwin_{{.Os}}_{{.Arch}}/coder
36+
37+
env:
38+
# Apple identity for signing!
39+
- AC_APPLICATION_IDENTITY=BDB050EB749EDD6A80C6F119BF1382ECA119CCCC
40+
41+
nfpms:
42+
- id: packages
43+
vendor: Coder
44+
homepage: https://coder.com
45+
maintainer: Coder <support@coder.com>
46+
description: |
47+
Provision development environments with infrastructure with code
48+
formats:
49+
- apk
50+
- deb
51+
- rpm
52+
suggests:
53+
- postgresql
54+
builds:
55+
- coder-linux
56+
bindir: /usr/bin
57+
contents:
58+
- src: coder.env
59+
dst: /etc/coder.d/coder.env
60+
type: "config|noreplace"
61+
- src: coder.service
62+
dst: /usr/lib/systemd/system/coder.service
63+
64+
# Image templates are empty on snapshots to avoid lengthy builds for
65+
# development.
66+
dockers:
67+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-amd64{{ end }}"]
68+
id: coder-linux
69+
dockerfile: Dockerfile
70+
use: buildx
71+
build_flag_templates:
72+
- --platform=linux/amd64
73+
- --label=org.opencontainers.image.title=Coder
74+
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
75+
- --label=org.opencontainers.image.url=https://github.com/coder/coder
76+
- --label=org.opencontainers.image.source=https://github.com/coder/coder
77+
- --label=org.opencontainers.image.version={{ .Version }}
78+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
79+
- --label=org.opencontainers.image.licenses=AGPL-3.0
80+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-arm64{{ end }}"]
81+
goarch: arm64
82+
dockerfile: Dockerfile
83+
use: buildx
84+
build_flag_templates:
85+
- --platform=linux/arm64/v8
86+
- --label=org.opencontainers.image.title=coder
87+
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
88+
- --label=org.opencontainers.image.url=https://github.com/coder/coder
89+
- --label=org.opencontainers.image.source=https://github.com/coder/coder
90+
- --label=org.opencontainers.image.version={{ .Tag }}
91+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
92+
- --label=org.opencontainers.image.licenses=AGPL-3.0
93+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-armv7{{ end }}"]
94+
goarch: arm
95+
goarm: "7"
96+
dockerfile: Dockerfile
97+
use: buildx
98+
build_flag_templates:
99+
- --platform=linux/arm/v7
100+
- --label=org.opencontainers.image.title=Coder
101+
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
102+
- --label=org.opencontainers.image.url=https://github.com/coder/coder
103+
- --label=org.opencontainers.image.source=https://github.com/coder/coder
104+
- --label=org.opencontainers.image.version={{ .Tag }}
105+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
106+
- --label=org.opencontainers.image.licenses=AGPL-3.0
107+
108+
docker_manifests:
109+
- name_template: ghcr.io/coder/coder:{{ .Tag }}
110+
image_templates:
111+
- ghcr.io/coder/coder:{{ .Tag }}-amd64
112+
- ghcr.io/coder/coder:{{ .Tag }}-arm64
113+
- ghcr.io/coder/coder:{{ .Tag }}-armv7
114+
115+
release:
116+
ids: [release-prebuilt-linux, release-prebuilt-windows, release-prebuilt-darwin, packages]
117+
footer: |
118+
## Container Image
119+
- `docker pull ghcr.io/coder/coder:{{ .Tag }}`
120+
121+
signs:
122+
- ids: [coder-darwin]
123+
artifacts: archive
124+
cmd: ./scripts/sign_macos.sh
125+
args: ["${artifact}"]
126+
output: true

0 commit comments

Comments
 (0)