Skip to content

Commit 59cd2c7

Browse files
committed
fixup! chore: update release workflow to use new build scripts
1 parent 044780d commit 59cd2c7

File tree

5 files changed

+37
-29
lines changed

5 files changed

+37
-29
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
# In a non-snapshot we want the ./scripts/version.sh script to never generate a
2525
# +dev version.
2626
env:
27-
CODER_NO_DEV_VERSION: ${{ github.event.inputs.snapshot || 'true' }}
27+
CODER_NO_DEV_VERSION: ${{ github.event.inputs.snapshot && '' || 'true' }}
2828

2929
jobs:
3030
linux-windows:

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
FROM alpine
22

3+
# LABEL doesn't add any real layers so it's fine (and easier) to do it here than
4+
# in the build script.
5+
ARG CODER_VERSION
6+
LABEL \
7+
org.opencontainers.image.title="Coder" \
8+
org.opencontainers.image.description="A tool for provisioning self-hosted development environments with Terraform." \
9+
org.opencontainers.image.url="https://github.com/coder/coder" \
10+
org.opencontainers.image.source="https://github.com/coder/coder" \
11+
org.opencontainers.image.version="$CODER_VERSION" \
12+
org.opencontainers.image.licenses="AGPL-3.0"
13+
314
# The coder binary is injected by scripts/build_docker.sh.
415
ADD coder /opt/coder
516

scripts/build_docker.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,9 @@ ln -P Dockerfile "$temp_dir/"
9292
cd "$temp_dir"
9393

9494
build_args=(
95-
"--platform=$arch"
96-
"--label=org.opencontainers.image.title=Coder"
97-
"--label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform."
98-
"--label=org.opencontainers.image.url=https://github.com/coder/coder"
99-
"--label=org.opencontainers.image.source=https://github.com/coder/coder"
100-
"--label=org.opencontainers.image.version=$version"
101-
"--label=org.opencontainers.image.licenses=AGPL-3.0"
102-
"--tag=$image_tag"
95+
--platform "$arch"
96+
--build-arg "CODER_VERSION=$version"
97+
--tag "$image_tag"
10398
)
10499

105100
log "--- Building Docker image for $arch ($image_tag)"

scripts/build_docker_multiarch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ for image_tag in "$@"; do
5959
create_args+=(--amend "$image_tag")
6060
done
6161

62+
# Sadly, multi-arch images don't seem to support labels.
6263
output_tag="$(execrelative ./image_tag.sh --version "$version")"
6364
log "--- Creating multi-arch Docker image ($output_tag)"
6465
docker manifest create \

scripts/lib.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66

77
set -euo pipefail
88

9+
# realpath returns an absolute path to the given relative path. It will fail if
10+
# the parent directory of the path does not exist. Make sure you are in the
11+
# expected directory before running this to avoid errors.
12+
#
13+
# GNU realpath relies on coreutils, which are not installed or the default on
14+
# Macs out of the box, so we have this mostly working bash alternative instead.
15+
#
16+
# Taken from https://stackoverflow.com/a/3915420 (CC-BY-SA 4.0)
17+
realpath() {
18+
dir="$(dirname "$1")"
19+
base="$(basename "$1")"
20+
if [[ ! -d "$dir" ]]; then
21+
error "Could not change directory to '$dir': directory does not exist"
22+
fi
23+
echo "$(
24+
cd "$dir" || error "Could not change directory to '$dir'"
25+
pwd -P
26+
)"/"$base"
27+
}
28+
29+
# We have to define realpath before these otherwise it fails on Mac's bash.
930
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
1031
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(git rev-parse --show-toplevel)")"
1132

@@ -40,26 +61,6 @@ execrelative() {
4061
popd
4162
}
4263

43-
# realpath returns an absolute path to the given relative path. It will fail if
44-
# the parent directory of the path does not exist. Make sure you are in the
45-
# expected directory before running this to avoid errors.
46-
#
47-
# GNU realpath relies on coreutils, which are not installed or the default on
48-
# Macs out of the box, so we have this mostly working bash alternative instead.
49-
#
50-
# Taken from https://stackoverflow.com/a/3915420 (CC-BY-SA 4.0)
51-
realpath() {
52-
dir="$(dirname "$1")"
53-
base="$(basename "$1")"
54-
if [[ ! -d "$dir" ]]; then
55-
error "Could not change directory to '$dir': directory does not exist"
56-
fi
57-
echo "$(
58-
cd "$dir" || error "Could not change directory to '$dir'"
59-
pwd -P
60-
)"/"$base"
61-
}
62-
6364
# maybedryrun prints the given program and flags, and then, if the first
6465
# argument is 0, executes it. The reason the first argument should be 0 is that
6566
# it is expected that you have a dry_run variable in your script that is set to

0 commit comments

Comments
 (0)