Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! chore: split release workflow so the majority happens on Linux
  • Loading branch information
deansheather committed Jun 6, 2022
commit 9ddb587dc11733d7d2bd938349f26e6551fc6c77
43 changes: 14 additions & 29 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,17 @@ jobs:
- name: Build Site
run: make site/out/index.html

- name: Build Linux binaries with GoReleaser
- name: Build Linux and Windows binaries with GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: build --rm-dist --timeout 60m --id coder-linux
args: release -f ./.goreleaser-linux.yaml --rm-dist --timeout 60m --snapshot

- name: Build Windows binaries with GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: build --rm-dist --timeout 60m --id coder-windows

- name: Upload Linux binary artifacts
- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
name: linux
path: ./dist/coder-linux-*

- name: Upload Windows binary artifacts
uses: actions/upload-artifact@v3
with:
name: windows
path: ./dist/coder-windows-*
path: ./dist/coder*

# The mac binaries get built on mac runners because they need to be signed,
# and the signing tool only runs on mac. This darwin job only builds the Mac
Expand Down Expand Up @@ -133,11 +121,11 @@ jobs:
- name: Build Site
run: make site/out/index.html

- name: Build darwin binaries with GoReleaser
- name: Build Darwin binaries with GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: build --rm-dist --timeout 60m --id coder-darwin
args: release -f ./.goreleaser-darwin.yaml --rm-dist --timeout 60m --snapshot
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
Expand All @@ -146,7 +134,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: darwin
path: ./dist/coder-darwin-*
path: ./dist/coder*

publish:
runs-on: ubuntu-latest
Expand All @@ -171,23 +159,20 @@ jobs:
- name: mkdir artifacts
run: mkdir artifacts

- name: Download Linux artifacts
- name: Download darwin artifacts
uses: actions/download-artifact@v3
with:
name: linux
name: darwin
path: ./artifacts

- name: Download Windows artifacts
- name: Download Linux and Windows artifacts
uses: actions/download-artifact@v3
with:
name: windows
name: linux
path: ./artifacts

- name: Download darwin artifacts
uses: actions/download-artifact@v3
with:
name: darwin
path: ./artifacts
- name: ls ./artifacts
run: ls ./artifacts

# This will build Docker images and Linux packages.
- name: Publish release
Expand All @@ -196,7 +181,7 @@ jobs:
# we use the "prebuilt" builder here which is a pro-only feature
distribution: goreleaser-pro
version: latest
args: release -f ./.goreleaser-release.yaml --rm-dist --timeout 60m
args: release -f ./.goreleaser-release.yaml --rm-dist --timeout 60m --snapshot
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
57 changes: 57 additions & 0 deletions .goreleaser-release-darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
before:
hooks:
- go mod tidy
- rm -f site/out/bin/coder*

archives:
- id: coder-darwin
builds: [coder-darwin]
format: zip

builds:
- id: coder-slim
dir: cmd/coder
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [darwin, linux, windows]
goarch: [amd64, arm, arm64]
goarm: ["7"]
# Only build arm 7 for Linux
ignore:
- goos: windows
goarm: "7"
- goos: darwin
goarm: "7"
hooks:
# The "trimprefix" appends ".exe" on Windows.
post: |
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ trimprefix .Name "coder" }}

- id: coder-darwin
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [darwin]
goarch: [amd64, arm64]
hooks:
# This signs the binary that will be located inside the zip.
# MacOS requires the binary to be signed for notarization.
#
# If it doesn't successfully sign, the zip sign step will error.
post: |
sh -c 'codesign -s {{.Env.AC_APPLICATION_IDENTITY}} -f -v --timestamp --options runtime {{.Path}} || true'

env:
# Apple identity for signing!
- AC_APPLICATION_IDENTITY=BDB050EB749EDD6A80C6F119BF1382ECA119CCCC

signs:
- ids: [coder-darwin]
artifacts: archive
cmd: ./scripts/sign_macos.sh
args: ["${artifact}"]
output: true

snapshot:
name_template: "{{ .Version }}-devel+{{ .ShortCommit }}"
52 changes: 52 additions & 0 deletions .goreleaser-release-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
before:
hooks:
- go mod tidy
- rm -f site/out/bin/coder*

archives:
- id: coder-linux
builds: [coder-linux]
format: tar.gz

- id: coder-windows
builds: [coder-windows]
format: zip

builds:
- id: coder-slim
dir: cmd/coder
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [darwin, linux, windows]
goarch: [amd64, arm, arm64]
goarm: ["7"]
# Only build arm 7 for Linux
ignore:
- goos: windows
goarm: "7"
- goos: darwin
goarm: "7"
hooks:
# The "trimprefix" appends ".exe" on Windows.
post: |
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ trimprefix .Name "coder" }}

- id: coder-linux
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [linux]
goarch: [amd64, arm, arm64]
goarm: ["7"]

- id: coder-windows
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [windows]
goarch: [amd64, arm64]

snapshot:
name_template: "{{ .Version }}-devel+{{ .ShortCommit }}"
45 changes: 9 additions & 36 deletions .goreleaser-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ archives:
builds: [release-prebuilt-linux]
format: tar.gz

- id: coder-windows
builds: [release-prebuilt-windows]
format: zip

- id: coder-darwin
builds: [release-prebuilt-darwin]
format: zip

builds:
- id: release-prebuilt-linux
builder: prebuilt
Expand All @@ -20,24 +12,7 @@ builds:
prebuilt:
path: artifacts/coder-linux_{{.Os}}_{{.Arch}}/coder

- id: release-prebuilt-windows
builder: prebuilt
goos: [windows]
goarch: [amd64, arm64]
prebuilt:
path: artifacts/coder-windows_{{.Os}}_{{.Arch}}/coder.exe

- id: release-prebuilt-darwin
builder: prebuilt
goos: [darwin]
goarch: [amd64, arm64]
prebuilt:
path: artifacts/coder-darwin_{{.Os}}_{{.Arch}}/coder

env:
# Apple identity for signing!
- AC_APPLICATION_IDENTITY=BDB050EB749EDD6A80C6F119BF1382ECA119CCCC

# This section is also contained in .goreleaser.yaml.
nfpms:
- id: packages
vendor: Coder
Expand All @@ -52,7 +27,7 @@ nfpms:
suggests:
- postgresql
builds:
- coder-linux
- release-prebuilt-linux
bindir: /usr/bin
contents:
- src: coder.env
Expand All @@ -65,7 +40,7 @@ nfpms:
# development.
dockers:
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-amd64{{ end }}"]
id: coder-linux
id: release-prebuilt-linux
dockerfile: Dockerfile
use: buildx
build_flag_templates:
Expand Down Expand Up @@ -113,14 +88,12 @@ docker_manifests:
- ghcr.io/coder/coder:{{ .Tag }}-armv7

release:
ids: [release-prebuilt-linux, release-prebuilt-windows, release-prebuilt-darwin, packages]
ids: [release-prebuilt-linux, packages]
footer: |
## Container Image
- `docker pull ghcr.io/coder/coder:{{ .Tag }}`

signs:
- ids: [coder-darwin]
artifacts: archive
cmd: ./scripts/sign_macos.sh
args: ["${artifact}"]
output: true
# All non-Linux files should just be used as is. We have to import the Linux
# builds so that the docker images get built and package creation works.
extra_files:
- glob: ./artifacts/coder_*_darwin*
- glob: ./artifacts/coder_*_windows*