Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6da0a6

Browse files
authored
ci: Fix silent missing metadata for release notes (#6089)
* Fix use of `mapfile < <(cmd)` which silently hid errors * Fix script paths since `SCRIPT_DIR` changed in `lib.sh` * Set `GITHUB_TOKEN` in release.yaml
1 parent 1dc4778 commit f6da0a6

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

.github/workflows/release.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
6464
- name: Create release notes
6565
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6667
# We always have to set this since there might be commits on
6768
# main that didn't have a PR.
6869
CODER_IGNORE_MISSING_COMMIT_METADATA: "1"

scripts/release.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ fi
100100
# Check the current version tag from GitHub (by number) using the API to
101101
# ensure no local tags are considered.
102102
log "Checking GitHub for latest release..."
103-
mapfile -t versions < <(gh api -H "Accept: application/vnd.github+json" /repos/coder/coder/git/refs/tags -q '.[].ref | split("/") | .[2]' | grep '^v' | sort -r -V)
103+
versions_out="$(gh api -H "Accept: application/vnd.github+json" /repos/coder/coder/git/refs/tags -q '.[].ref | split("/") | .[2]' | grep '^v' | sort -r -V)"
104+
mapfile -t versions <<<"$versions_out"
104105
old_version=${versions[0]}
105106
log "Latest release: $old_version"
106107
log
@@ -156,15 +157,16 @@ log 'Waiting for job to become "in_progress"...'
156157

157158
# Wait at most 3 minutes (3*60)/3 = 60 for the job to start.
158159
for _ in $(seq 1 60); do
159-
mapfile -t run < <(
160+
output="$(
160161
# Output:
161162
# 3886828508
162163
# in_progress
163164
gh run list -w release.yaml \
164165
--limit 1 \
165166
--json status,databaseId \
166167
--jq '.[] | (.databaseId | tostring), .status'
167-
)
168+
)"
169+
mapfile -t run <<<"$output"
168170
if [[ ${run[1]} != "in_progress" ]]; then
169171
sleep 3
170172
continue

scripts/release/check_commit_metadata.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ main() {
5353
security_label=security
5454

5555
# Get abbreviated and full commit hashes and titles for each commit.
56-
mapfile -t commits < <(git log --no-merges --pretty=format:"%h %H %s" "$range")
56+
git_log_out="$(git log --no-merges --pretty=format:"%h %H %s" "$range")"
57+
mapfile -t commits <<<"$git_log_out"
5758

5859
# If this is a tag, use rev-list to find the commit it points to.
5960
from_commit=$(git rev-list -n 1 "$from_ref")
@@ -69,18 +70,18 @@ main() {
6970
# 27386d49d08455b6f8fbf2c18f38244d03fda892 author:hello labels:label:security
7071
# d9f2aaf3b430d8b6f3d5f24032ed6357adaab1f1 author:world
7172
# fd54512858c906e66f04b0744d8715c2e0de97e6 author:bye labels:label:stale label:enhancement
72-
from_commit_date=2023-01-18
73-
mapfile -t pr_labels_raw < <(
73+
pr_list_out="$(
7474
gh pr list \
7575
--base main \
7676
--state merged \
7777
--limit 10000 \
7878
--search "merged:>=$from_commit_date" \
7979
--json mergeCommit,labels,author \
8080
--jq '.[] | "\( .mergeCommit.oid ) author:\( .author.login ) labels:\(["label:\( .labels[].name )"] | join(" "))"'
81-
)
81+
)"
82+
mapfile -t pr_metadata_raw <<<"$pr_list_out"
8283
declare -A authors labels
83-
for entry in "${pr_labels_raw[@]}"; do
84+
for entry in "${pr_metadata_raw[@]}"; do
8485
commit_sha_long=${entry%% *}
8586
commit_author=${entry#* author:}
8687
commit_author=${commit_author%% *}

scripts/release/generate_release_notes.sh

+5-6
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ if [[ -z $ref ]]; then
5959
fi
6060

6161
# shellcheck source=scripts/release/check_commit_metadata.sh
62-
source "$SCRIPT_DIR/release/check_commit_metadata.sh" "$old_version" "$ref"
62+
source "$SCRIPT_DIR/check_commit_metadata.sh" "$old_version" "$ref"
6363

6464
# Sort commits by title prefix, then by date, only return sha at the end.
65-
mapfile -t commits < <(git log --no-merges --pretty=format:"%ct %h %s" "$old_version..$ref" | sort -k3,3 -k1,1n | cut -d' ' -f2)
65+
git_log_out="$(git log --no-merges --pretty=format:"%ct %h %s" "$old_version..$ref" | sort -k3,3 -k1,1n | cut -d' ' -f2)"
66+
mapfile -t commits <<<"$git_log_out"
6667

6768
# From: https://github.com/commitizen/conventional-commit-types
6869
# NOTE(mafredri): These need to be supported in check_commit_metadata.sh as well.
@@ -138,7 +139,7 @@ changelog="$(
138139
done
139140
)"
140141

141-
image_tag="$(execrelative ./image_tag.sh --version "$new_version")"
142+
image_tag="$(execrelative ../image_tag.sh --version "$new_version")"
142143

143144
echo -e "## Changelog
144145
$changelog
@@ -151,7 +152,5 @@ Compare: [\`$old_version...$new_version\`](https://github.com/coder/coder/compar
151152
152153
## Install/upgrade
153154
154-
Refer to our docs to [install](https://coder.com/docs/v2/latest/install)
155-
or [upgrade](https://coder.com/docs/v2/latest/admin/upgrade) Coder, or use
156-
a release asset below.
155+
Refer to our docs to [install](https://coder.com/docs/v2/latest/install) or [upgrade](https://coder.com/docs/v2/latest/admin/upgrade) Coder, or use a release asset below.
157156
"

scripts/release/tag_version.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ref=$(git rev-parse --short "$ref")
8282

8383
log "Checking commit metadata for changes since $old_version..."
8484
# shellcheck source=scripts/release/check_commit_metadata.sh
85-
source "$SCRIPT_DIR/release/check_commit_metadata.sh" "$old_version" "$ref"
85+
source "$SCRIPT_DIR/check_commit_metadata.sh" "$old_version" "$ref"
8686

8787
if ((COMMIT_METADATA_BREAKING == 1)); then
8888
prev_increment=$increment

0 commit comments

Comments
 (0)