Skip to content

Commit 94a6fcd

Browse files
committed
fixup! chore: make dependency checks nicer
1 parent a19ef36 commit 94a6fcd

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

scripts/publish_release.sh

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ if [[ "$version" == "" ]]; then
5959
version="$(execrelative ./version.sh)"
6060
fi
6161

62+
# realpath-ify all input files so we can cdroot below.
63+
files=()
64+
for f in "$@"; do
65+
if [[ ! -e "$f" ]]; then
66+
error "File not found: $f"
67+
fi
68+
files+=("$(realpath "$f")")
69+
done
70+
if [[ "${#files[@]}" == 0 ]]; then
71+
error "No files supplied"
72+
fi
73+
74+
# The git commands need to be executed from within the repository.
75+
cdroot
76+
6277
# Verify that we're currently checked out on the supplied tag.
6378
new_tag="v$version"
6479
if [[ "$(git describe --always)" != "$new_tag" ]]; then
@@ -80,24 +95,26 @@ if [[ "$dry_run" == 1 ]]; then
8095
fi
8196

8297
# Craft the release notes.
98+
changelog="$(git log --no-merges --pretty=format:"- %h %s" "$changelog_range")"
99+
image_tag="$(execrelative ./image_tag.sh --version "$version")"
83100
release_notes="
84101
## Changelog
85102
86-
$(git log --no-merges --pretty=format:"- %h %s" "$changelog_range")
103+
$changelog
87104
88105
## Container Image
89-
- \`docker pull $(execrelative ./image_tag.sh --version "$version")\`
106+
- \`docker pull $image_tag\`
90107
91108
"
92109

93-
# Create temporary release folder so we can generate checksums.
110+
# Create temporary release folder so we can generate checksums. Both the
111+
# sha256sum and gh binaries support symlinks as input files so this works well.
94112
temp_dir="$(mktemp -d)"
95-
for f in "$@"; do
96-
ln -s "$(realpath "$f")" "$temp_dir/"
113+
for f in "${files[@]}"; do
114+
ln -s "$f" "$temp_dir/"
97115
done
98116

99-
# Generate checksums file. sha256sum seems to play nicely with symlinks so this
100-
# works well.
117+
# Generate checksums file which will be uploaded to the GitHub release.
101118
pushd "$temp_dir"
102119
sha256sum ./* | sed -e 's/\.\///' - >"coder_${version}_checksums.txt"
103120
popd
@@ -116,8 +133,6 @@ log
116133

117134
# We echo the release notes in instead of writing to a file and referencing that
118135
# to prevent GitHub CLI from becoming interactive.
119-
#
120-
# GitHub CLI seems to follow symlinks when uploading files.
121136
echo "$release_notes" |
122137
maybedryrun "$dry_run" gh release create \
123138
--title "$new_tag" \

0 commit comments

Comments
 (0)