Skip to content

Remove goreleaser in favor of build scripts #2143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bc06a6f
chore: write build_go.sh script and dependencies
deansheather Jun 7, 2022
850bc82
chore: write build_go_matrix.sh and archive.sh
deansheather Jun 8, 2022
e847230
fixup! chore: write build_go_matrix.sh and archive.sh
deansheather Jun 8, 2022
4edb649
fixup! chore: write build_go_matrix.sh and archive.sh
deansheather Jun 8, 2022
4ed419c
merge main
deansheather Jun 8, 2022
cef0221
chore: add scripts for packages
deansheather Jun 8, 2022
64f9648
chore: add scripts for building a docker image
deansheather Jun 8, 2022
998bc31
chore: add docker multi-arch script and release script
deansheather Jun 9, 2022
46b5d79
fixup! chore: add docker multi-arch script and release script
deansheather Jun 9, 2022
9e279a9
chore: fix indenting
deansheather Jun 9, 2022
4885076
chore: update makefile to use new build scripts
deansheather Jun 9, 2022
044780d
chore: update release workflow to use new build scripts
deansheather Jun 10, 2022
59cd2c7
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
d1edee5
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
4f03e37
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
5c9dd9e
fixup! chore: update release workflow to use new build scripts
deansheather Jun 12, 2022
e09edfd
fixup! chore: update release workflow to use new build scripts
deansheather Jun 13, 2022
4dd6f4d
chore: add dependency checks to release scripts
deansheather Jun 13, 2022
72d8b50
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
17cda1f
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
6a4bc44
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
e150438
fixup! chore: add dependency checks to release scripts
deansheather Jun 13, 2022
449a1a1
chore: make dependency checks nicer
deansheather Jun 14, 2022
ba78076
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
a19ef36
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
94a6fcd
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
c524507
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
48eaa18
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
ce3f4f5
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
4886542
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
d4631ad
fixup! chore: make dependency checks nicer
deansheather Jun 14, 2022
a0c9a96
chore: integrate docker into pipeline
deansheather Jun 15, 2022
0907c37
fixup! chore: integrate docker into pipeline
deansheather Jun 15, 2022
4a94e25
fixup! chore: integrate docker into pipeline
deansheather Jun 16, 2022
37badc3
Merge branch 'main' into remove-goreleaser
deansheather Jun 16, 2022
173031f
chore: add version checks to lib.sh
deansheather Jun 16, 2022
ae48f20
fixup! chore: add version checks to lib.sh
deansheather Jun 16, 2022
d8a624c
fixup! chore: add version checks to lib.sh
deansheather Jun 16, 2022
6f2b997
Merge branch 'main' into remove-goreleaser
deansheather Jun 18, 2022
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
chore: integrate docker into pipeline
  • Loading branch information
deansheather committed Jun 15, 2022
commit a0c9a964981e8b4ee26820a44fb192b917ca2836
34 changes: 34 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:

- name: Build Linux and Windows Binaries
run: |
set -euo pipefail
go mod download

mkdir -p ./dist
Expand All @@ -76,6 +77,37 @@ jobs:
linux:amd64,armv7,arm64 \
windows:amd64,arm64

- name: Build Linux Docker images
run: |
set -euo pipefail

# build and push Docker images for each architecture
images=()
for arch in amd64 armv7 arm64; do
img="$(
./scripts/build_docker.sh \
${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot && '--push' }} \
--arch "$arch" \
./dist/coder_*_linux_"$arch"
)"
images+=("$img")
done

# build and push multi-arch manifest
./scripts/build_docker_multiarch.sh \
${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot && '--push' }} \
"${images[@]}"

# if the current version is equal to the highest (according to semver)
# version in the repo, also create a multi-arch image as ":latest" and
# push it
if [[ "$(git tag | grep '^v' | grep -vE '(rc|dev|-|\+|\/)' | sort -r --version-sort | head -n1)" == "v$(./scripts/version.sh)" ]]; then
./scripts/build_docker_multiarch.sh \
--target "$(./scripts/image_tag.sh --version latest)" \
${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot && '--push' }} \
"${images[@]}"
fi

- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -120,6 +152,7 @@ jobs:

- name: Install dependencies
run: |
set -euo pipefail
# The version of bash that MacOS ships with is too old
brew install bash

Expand All @@ -140,6 +173,7 @@ jobs:

- name: Build darwin Binaries (with signatures)
run: |
set -euo pipefail
go mod download

mkdir -p ./dist
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"
services:
coder:
image: ghcr.io/coder/coder:v${CODER_VERSION:-0.5.10}
image: ghcr.io/coder/coder:v${CODER_VERSION:-latest}
ports:
- "7080:7080"
environment:
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This script builds a Docker image of Coder containing the given binary, for
# the given architecture. Only linux binaries are supported at this time.
#
# Usage: ./build_docker.sh --arch amd64 [--version 1.2.3] [--push]
# Usage: ./build_docker.sh --arch amd64 [--version 1.2.3] [--push] path/to/coder
#
# The --arch parameter is required and accepts a Golang arch specification. It
# will be automatically mapped to a suitable architecture that Docker accepts
Expand Down Expand Up @@ -80,6 +80,7 @@ declare -A arch_map=(
[amd64]="linux/amd64"
[arm64]="linux/arm64"
[arm]="linux/arm/v7"
[armv7]="linux/arm/v7"
)
if [[ "${arch_map[$arch]+exists}" != "" ]]; then
arch="${arch_map[$arch]}"
Expand Down
32 changes: 22 additions & 10 deletions scripts/build_docker_multiarch.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env bash

# This script merges Coder Docker images of different architectures together
# into the archless image tag returned by ./image_tag.sh.
# into the specified target image+tag, or the arch-less image tag returned by
# ./image_tag.sh.
#
# Usage: ./build_docker_multiarch.sh [--version 1.2.3] [--push] image1:tag1 image2:tag2
# Usage: ./build_docker_multiarch.sh [--version 1.2.3] [--target image:tag] [--push] image1:tag1 image2:tag2
#
# The supplied images must already be pushed to the registry or this will fail.
# Also, the source images cannot be in a different registry than the target
# image generated by ./image_tag.sh.
# image.
#
# If no version is specified, defaults to the version from ./version.sh.
#
# If no target tag is supplied, the arch-less image tag returned by
# ./image_tag.sh will be used.
#
# If the --push parameter is supplied, all supplied tags will be pushed.
#
# Returns the merged image tag.
Expand All @@ -20,16 +24,21 @@ set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"

version=""
target=""
push=0

args="$(getopt -o "" -l version:,push -- "$@")"
args="$(getopt -o "" -l version:,target:,push -- "$@")"
eval set -- "$args"
while true; do
case "$1" in
--version)
version="$2"
shift 2
;;
--target)
target="$2"
shift 2
;;
--push)
push=1
shift
Expand Down Expand Up @@ -57,21 +66,24 @@ if [[ "$version" == "" ]]; then
version="$(execrelative ./version.sh)"
fi

if [[ "$target" == "" ]]; then
target="$(execrelative ./image_tag.sh --version "$version")"
fi

create_args=()
for image_tag in "$@"; do
create_args+=(--amend "$image_tag")
done

# Sadly, multi-arch images don't seem to support labels.
output_tag="$(execrelative ./image_tag.sh --version "$version")"
log "--- Creating multi-arch Docker image ($output_tag)"
log "--- Creating multi-arch Docker image ($target)"
docker manifest create \
"$output_tag" \
"$target" \
"${create_args[@]}"

if [[ "$push" == 1 ]]; then
log "--- Pushing multi-arch Docker image ($output_tag)"
docker push "$output_tag"
log "--- Pushing multi-arch Docker image ($target)"
docker manifest push "$target"
fi

echo "$output_tag"
echo "$target"
8 changes: 6 additions & 2 deletions scripts/image_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
# The --arch parameter accepts a Golang arch specification. If not specified,
# the image tag for the multi-arch image will be returned instead.
#
# If no version is specified, defaults to the version from ./version.sh.
# If no version is specified, defaults to the version from ./version.sh. If the
# supplied version is "latest", no `v` prefix will be added to the tag.
#
# The returned tag will be sanitized to remove invalid characters like the plus
# sign.
Expand Down Expand Up @@ -42,14 +43,17 @@ while true; do
esac
done

# Remove the "v" prefix.
# Remove the "v" prefix because we don't want to add it twice.
version="${version#v}"
if [[ "$version" == "" ]]; then
version="$(execrelative ./version.sh)"
fi

image="${CODER_IMAGE_BASE:-ghcr.io/coder/coder}"
tag="v$version"
if [[ "$version" == "latest" ]]; then
tag="latest"
fi
if [[ "$arch" != "" ]]; then
tag+="-$arch"
fi
Expand Down