7
7
8
8
usage () {
9
9
cat << EOH
10
- Usage: ./release.sh [--branch <name>] [--draft] [-- dry-run] [--ref <ref>] [--major | --minor | --patch]
10
+ Usage: ./release.sh [--dry-run] [--ref <ref>] [--major | --minor | --patch]
11
11
12
12
This script should be called to create a new release.
13
13
@@ -23,47 +23,24 @@ be tagged at, otherwise the latest commit will be used.
23
23
Set --minor to force a minor version bump, even when there are no breaking
24
24
changes. Likewise for --major. By default a patch version will be created.
25
25
26
- Set --dry-run to run the release workflow in CI as a dry-run (no release will
27
- be created).
26
+ Set --dry-run to see what this script would do without making actual changes.
28
27
29
28
To mark a release as containing breaking changes, the commit title should
30
29
either contain a known prefix with an exclamation mark ("feat!:",
31
30
"feat(api)!:") or the PR that was merged can be tagged with the
32
31
"release/breaking" label.
33
-
34
- To test changes to this script, you can set --branch <my-branch>, which will
35
- run the release workflow in CI as a dry-run and use the latest commit on the
36
- specified branch as the release commit. This will also set --dry-run.
37
32
EOH
38
33
}
39
34
40
- # Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way than via
41
- # --branch.
42
- if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:- 0} != 0 ]]; then
43
- log " WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled externally, we will ignore missing commit metadata."
44
- fi
45
-
46
35
branch=main
47
- draft=0
48
36
dry_run=0
49
37
ref=
50
38
increment=
51
39
52
- args=" $( getopt -o h -l branch:,draft, dry-run,help,ref:,major,minor,patch -- " $@ " ) "
40
+ args=" $( getopt -o h -l dry-run,help,ref:,major,minor,patch -- " $@ " ) "
53
41
eval set -- " $args "
54
42
while true ; do
55
43
case " $1 " in
56
- --branch)
57
- branch=" $2 "
58
- log " Using branch $branch , implies DRYRUN and CODER_IGNORE_MISSING_COMMIT_METADATA."
59
- dry_run=1
60
- export CODER_IGNORE_MISSING_COMMIT_METADATA=1
61
- shift 2
62
- ;;
63
- --draft)
64
- draft=1
65
- shift
66
- ;;
67
44
--dry-run)
68
45
dry_run=1
69
46
shift
115
92
116
93
# Check the current version tag from GitHub (by number) using the API to
117
94
# ensure no local tags are considered.
95
+ log " Checking GitHub for latest release..."
118
96
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)
119
97
old_version=${versions[0]}
98
+ log " Latest release: $old_version "
99
+ log
120
100
121
101
trap ' log "Check commit metadata failed, you can try to set \"export CODER_IGNORE_MISSING_COMMIT_METADATA=1\" and try again, if you know what you are doing."' EXIT
122
102
# shellcheck source=scripts/release/check_commit_metadata.sh
123
103
source " $SCRIPT_DIR /release/check_commit_metadata.sh" " $old_version " " $ref "
124
104
trap - EXIT
125
105
126
- new_version=" $( execrelative ./release/tag_version.sh --dry-run --ref " $ref " --" $increment " ) "
106
+ log " Executing DRYRUN of release tagging..."
107
+ new_version=" $( execrelative ./release/tag_version.sh --old-version " $old_version " --ref " $ref " --" $increment " --dry-run) "
108
+ log
109
+ read -p " Continue? (y/n) " -n 1 -r continue_release
110
+ log
111
+ if ! [[ $continue_release =~ ^[Yy]$ ]]; then
112
+ exit 0
113
+ fi
114
+
127
115
release_notes=" $( execrelative ./release/generate_release_notes.sh --old-version " $old_version " --new-version " $new_version " --ref " $ref " ) "
128
116
129
- log
130
117
read -p " Preview release notes? (y/n) " -n 1 -r show_reply
131
118
log
132
119
if [[ $show_reply =~ ^[Yy]$ ]]; then
120
+ log
133
121
echo -e " $release_notes \n"
134
122
fi
135
123
136
- create_message=" Create release"
137
- if (( draft)) ; then
138
- create_message=" Create draft release"
139
- fi
140
- if (( dry_run)) ; then
141
- create_message+=" (DRYRUN)"
142
- fi
143
- read -p " $create_message ? (y/n) " -n 1 -r create
124
+ read -p " Create release? (y/n) " -n 1 -r create
144
125
log
145
126
if ! [[ $create =~ ^[Yy]$ ]]; then
146
127
exit 0
147
128
fi
148
129
149
- args=()
130
+ log
131
+ # Run without dry-run to actually create the tag, note we don't update the
132
+ # new_version variable here to ensure we're pushing what we showed before.
133
+ maybedryrun " $dry_run " execrelative ./release/tag_version.sh --old-version " $old_version " --ref " $ref " --" $increment " > /dev/null
134
+ maybedryrun " $dry_run " git push --tags -u origin " $new_version "
150
135
151
- # Draft and dry-run are required args.
152
- if (( draft)) ; then
153
- args+=(-F draft=true)
154
- else
155
- args+=(-F draft=false)
156
- fi
157
136
if (( dry_run)) ; then
158
- args+=(-F dry_run=true)
159
- else
160
- args+=(-F dry_run=false)
161
-
162
- # We only set this on non-dry-run releases because it will show a
163
- # warning in CI.
164
- if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:- 0} == 1 ]]; then
165
- args+=(-F ignore_missing_commit_metadata=true)
166
- fi
137
+ # We can't watch the release.yaml workflow if we're in dry-run mode.
138
+ exit 0
167
139
fi
168
140
169
141
log
170
- logrun gh workflow run release.yaml \
171
- --ref " $branch " \
172
- -F increment=" $increment " \
173
- " ${args[@]} "
174
- log
175
-
176
142
read -p " Watch release? (y/n) " -n 1 -r watch
177
143
log
178
144
if ! [[ $watch =~ ^[Yy]$ ]]; then
0 commit comments