Skip to content

Commit 044780d

Browse files
committed
chore: update release workflow to use new build scripts
1 parent 4885076 commit 044780d

File tree

2 files changed

+140
-41
lines changed

2 files changed

+140
-41
lines changed

.github/workflows/release.yaml

Lines changed: 138 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,95 @@
1+
# GitHub release workflow.
2+
#
3+
# This workflow is a bit complicated because we have to build darwin binaries on
4+
# a mac runner, but the mac runners are extremely slow. So instead of running
5+
# the entire release on a mac (which will take an hour to run), we run only the
6+
# mac build on a mac, and the rest on a linux runner. The final release is then
7+
# published using a final linux runner.
18
name: release
29
on:
310
push:
411
tags:
512
- "v*"
613
workflow_dispatch:
14+
inputs:
15+
snapshot:
16+
description: Allow a +dev version to be generated, implies dry_run.
17+
type: boolean
18+
required: true
19+
dry_run:
20+
description: Perform a dry-run release.
21+
type: boolean
22+
required: true
23+
24+
# In a non-snapshot we want the ./scripts/version.sh script to never generate a
25+
# +dev version.
26+
env:
27+
CODER_NO_DEV_VERSION: ${{ github.event.inputs.snapshot || 'true' }}
728

829
jobs:
9-
goreleaser:
10-
runs-on: macos-latest
11-
env:
12-
# Necessary for Docker manifest
13-
DOCKER_CLI_EXPERIMENTAL: "enabled"
30+
linux-windows:
31+
runs-on: ubuntu-latest
1432
steps:
15-
# Docker is not included on macos-latest
16-
- uses: docker-practice/actions-setup-docker@1.0.10
17-
1833
- uses: actions/checkout@v3
1934
with:
2035
fetch-depth: 0
2136

22-
- name: Set up QEMU
23-
uses: docker/setup-qemu-action@v2
37+
- uses: actions/setup-go@v3
38+
with:
39+
go-version: "~1.18"
2440

25-
- name: Docker Login
26-
uses: docker/login-action@v2
41+
- name: Cache Node
42+
id: cache-node
43+
uses: actions/cache@v3
2744
with:
28-
registry: ghcr.io
29-
username: ${{ github.repository_owner }}
30-
password: ${{ secrets.GITHUB_TOKEN }}
45+
path: |
46+
**/node_modules
47+
.eslintcache
48+
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
49+
restore-keys: |
50+
js-${{ runner.os }}-
51+
52+
- name: Build Site
53+
run: make site/out/index.html
54+
55+
- name: Build Slim Binaries
56+
run: make bin
57+
58+
- name: Build Linux and Windows Binaries
59+
run: |
60+
./scripts/build_go_matrix.sh \
61+
--output ./dist/ \
62+
--archive \
63+
--package-linux \
64+
linux:amd64,armv7,arm64 \
65+
windows:amd64,arm64
66+
67+
- name: Upload binary artifacts
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: linux
71+
path: |
72+
dist/*.zip
73+
dist/*.tar.gz
74+
dist/*.apk
75+
dist/*.deb
76+
dist/*.rpm
77+
78+
# The mac binaries get built on mac runners because they need to be signed,
79+
# and the signing tool only runs on mac. This darwin job only builds the Mac
80+
# binaries and uploads them as job artifacts used by the publish step.
81+
darwin:
82+
runs-on: macos-latest
83+
steps:
84+
- uses: actions/checkout@v3
85+
with:
86+
fetch-depth: 0
3187

3288
- uses: actions/setup-go@v3
3389
with:
3490
go-version: "~1.18"
3591

36-
- name: Install Gon
92+
- name: Install gon
3793
run: |
3894
brew tap mitchellh/gon
3995
brew install mitchellh/gon/gon
@@ -44,24 +100,6 @@ jobs:
44100
p12-file-base64: ${{ secrets.AC_CERTIFICATE_P12_BASE64 }}
45101
p12-password: ${{ secrets.AC_CERTIFICATE_PASSWORD }}
46102

47-
- name: Echo Go Cache Paths
48-
id: go-cache-paths
49-
run: |
50-
echo "::set-output name=go-build::$(go env GOCACHE)"
51-
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
52-
53-
- name: Go Build Cache
54-
uses: actions/cache@v3
55-
with:
56-
path: ${{ steps.go-cache-paths.outputs.go-build }}
57-
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
58-
59-
- name: Go Mod Cache
60-
uses: actions/cache@v3
61-
with:
62-
path: ${{ steps.go-cache-paths.outputs.go-mod }}
63-
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
64-
65103
- name: Cache Node
66104
id: cache-node
67105
uses: actions/cache@v3
@@ -79,12 +117,72 @@ jobs:
79117
- name: Build Site
80118
run: make site/out/index.html
81119

82-
- name: Run GoReleaser
83-
uses: goreleaser/goreleaser-action@v3
84-
with:
85-
version: latest
86-
args: release --rm-dist --timeout 60m
120+
- name: Build Slim Binaries
121+
run: make bin
122+
123+
- name: Build darwin Binaries (with signatures)
124+
run: |
125+
./scripts/build_go_matrix.sh \
126+
--output ./dist/ \
127+
--archive \
128+
--sign-darwin \
129+
darwin:amd64,arm64
87130
env:
88-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89131
AC_USERNAME: ${{ secrets.AC_USERNAME }}
90132
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
133+
134+
- name: Upload Binary Artifacts
135+
uses: actions/upload-artifact@v3
136+
with:
137+
name: darwin
138+
path: ./dist/coder_*.zip
139+
140+
publish:
141+
runs-on: ubuntu-latest
142+
needs:
143+
- linux-windows
144+
- darwin
145+
env:
146+
# Necessary for Docker manifest
147+
DOCKER_CLI_EXPERIMENTAL: "enabled"
148+
steps:
149+
- uses: actions/checkout@v3
150+
with:
151+
fetch-depth: 0
152+
153+
- name: Docker Login
154+
uses: docker/login-action@v2
155+
with:
156+
registry: ghcr.io
157+
username: ${{ github.repository_owner }}
158+
password: ${{ secrets.GITHUB_TOKEN }}
159+
160+
- name: mkdir artifacts
161+
run: mkdir artifacts
162+
163+
- name: Download darwin Artifacts
164+
uses: actions/download-artifact@v3
165+
with:
166+
name: darwin
167+
path: artifacts
168+
169+
- name: Download Linux and Windows Artifacts
170+
uses: actions/download-artifact@v3
171+
with:
172+
name: linux
173+
path: artifacts
174+
175+
- name: ls artifacts
176+
run: ls artifacts
177+
178+
- name: Publish Release
179+
run: |
180+
./scripts/publish_release.sh \
181+
${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \
182+
./artifacts/*.zip \
183+
./artifacts/*.tar.gz \
184+
./artifacts/*.apk \
185+
./artifacts/*.deb \
186+
./artifacts/*.rpm
187+
env:
188+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.DEFAULT_GOAL := build
22

3-
# use a single bash shell for each job, and immediately exit on failure
3+
# Use a single bash shell for each job, and immediately exit on failure
44
SHELL := bash
55
.SHELLFLAGS = -ceu
66
.ONESHELL:
@@ -18,6 +18,7 @@ bin: $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum
1818
@echo "== This builds slim binaries for command-line usage."
1919
@echo "== Use \"make build\" to embed the site."
2020

21+
mkdir -p ./dist
2122
rm -rf ./dist/coder-slim_*
2223
./scripts/build_go_slim.sh \
2324
--version "$(VERSION)" \

0 commit comments

Comments
 (0)