mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
ci: Revert to local tag creation and push for releases (#5714)
This commit is contained in:
@@ -91,10 +91,12 @@ main() {
|
||||
commit_sha_long=${parts[1]}
|
||||
commit_prefix=${parts[2]}
|
||||
|
||||
if [[ $ignore_missing_metadata != 1 ]]; then
|
||||
# Safety-check, guarantee all commits had their metadata fetched.
|
||||
if [[ ! -v labels[$commit_sha_long] ]]; then
|
||||
# Safety-check, guarantee all commits had their metadata fetched.
|
||||
if [[ ! -v labels[$commit_sha_long] ]]; then
|
||||
if [[ $ignore_missing_metadata != 1 ]]; then
|
||||
error "Metadata missing for commit $commit_sha_short"
|
||||
else
|
||||
log "WARNING: Metadata missing for commit $commit_sha_short"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -35,10 +35,9 @@ fi
|
||||
|
||||
version=""
|
||||
release_notes_file=""
|
||||
draft=0
|
||||
dry_run=0
|
||||
|
||||
args="$(getopt -o "" -l version:,release-notes-file:,draft,dry-run -- "$@")"
|
||||
args="$(getopt -o "" -l version:,release-notes-file:,dry-run -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
@@ -50,10 +49,6 @@ while true; do
|
||||
release_notes_file="$2"
|
||||
shift 2
|
||||
;;
|
||||
--draft)
|
||||
draft=1
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
dry_run=1
|
||||
shift
|
||||
@@ -134,20 +129,11 @@ popd
|
||||
log
|
||||
log
|
||||
|
||||
log "Pushing git tag"
|
||||
maybedryrun "$dry_run" git push --quiet origin "$new_tag"
|
||||
|
||||
args=()
|
||||
if ((draft)); then
|
||||
args+=(--draft)
|
||||
fi
|
||||
|
||||
# We pipe `true` into `gh` so that it never tries to be interactive.
|
||||
true |
|
||||
maybedryrun "$dry_run" gh release create \
|
||||
--title "$new_tag" \
|
||||
--notes-file "$release_notes_file" \
|
||||
"${args[@]}" \
|
||||
"$new_tag" \
|
||||
"$temp_dir"/*
|
||||
|
||||
|
||||
@@ -7,23 +7,27 @@ cdroot
|
||||
|
||||
usage() {
|
||||
cat <<EOH
|
||||
Usage: ./version_tag.sh [--dry-run] [--ref <ref>] <--major | --minor | --patch>
|
||||
Usage: ./version_tag.sh [--dry-run] [--old-version <version>] [--ref <ref>] <--major | --minor | --patch>
|
||||
|
||||
This script should be called to tag a new release. It will take the suggested
|
||||
increment (major, minor, patch) and optionally promote e.g. patch -> minor if
|
||||
there are breaking changes between the previous version and the given --ref
|
||||
(or HEAD).
|
||||
|
||||
This script will create a git tag, so it should only be run in CI (or via
|
||||
--dry-run).
|
||||
Pass --old-version optionally to ensure that the version is bumped from the
|
||||
provided version instead of the latest tag (for use in release.sh).
|
||||
|
||||
This script will create a git tag, it should only be called by release.sh or in
|
||||
CI.
|
||||
EOH
|
||||
}
|
||||
|
||||
dry_run=0
|
||||
old_version=
|
||||
ref=HEAD
|
||||
increment=
|
||||
|
||||
args="$(getopt -o h -l dry-run,help,ref:,major,minor,patch -- "$@")"
|
||||
args="$(getopt -o h -l dry-run,help,old-version:,ref:,major,minor,patch -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
@@ -31,6 +35,10 @@ while true; do
|
||||
dry_run=1
|
||||
shift
|
||||
;;
|
||||
--old-version)
|
||||
old_version="$2"
|
||||
shift 2
|
||||
;;
|
||||
--ref)
|
||||
ref="$2"
|
||||
shift 2
|
||||
@@ -63,20 +71,12 @@ if [[ -z $increment ]]; then
|
||||
error "No version increment provided."
|
||||
fi
|
||||
|
||||
if [[ $dry_run != 1 ]] && [[ ${CI:-} == "" ]]; then
|
||||
error "This script must be run in CI or with --dry-run."
|
||||
if [[ -z $old_version ]]; then
|
||||
old_version="$(git describe --abbrev=0 "$ref^1" --always)"
|
||||
fi
|
||||
|
||||
old_version="$(git describe --abbrev=0 "$ref^1")"
|
||||
cur_tag="$(git describe --abbrev=0 "$ref")"
|
||||
cur_tag="$(git describe --abbrev=0 "$ref" --always)"
|
||||
if [[ $old_version != "$cur_tag" ]]; then
|
||||
message="Ref \"$ref\" is already tagged with a release ($cur_tag)"
|
||||
if ! ((dry_run)); then
|
||||
error "$message."
|
||||
fi
|
||||
log "DRYRUN: $message, echoing current tag."
|
||||
echo "$cur_tag"
|
||||
exit 0
|
||||
error "A newer tag than \"$old_version\" already exists for \"$ref\" ($cur_tag), aborting."
|
||||
fi
|
||||
ref=$(git rev-parse --short "$ref")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user