2022-11-12 11:53:54am
This commit is contained in:
parent
8425c46f64
commit
b2a33c2cc6
3 changed files with 37 additions and 27 deletions
|
|
@ -1,10 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
. "$(dirname "$0")/../../ci/sub/lib.sh"
|
|
||||||
. "$(dirname "$0")/../../ci/sub/golib.sh"
|
|
||||||
cd -- "$(dirname "$0")/../.."
|
cd -- "$(dirname "$0")/../.."
|
||||||
|
. ./ci/sub/lib.sh
|
||||||
|
|
||||||
build() {(
|
build() {
|
||||||
OS="$1"
|
OS="$1"
|
||||||
ARCH="$2"
|
ARCH="$2"
|
||||||
BUILD_DIR="$BUILD_DIR/$OS/$ARCH"
|
BUILD_DIR="$BUILD_DIR/$OS/$ARCH"
|
||||||
|
|
@ -17,17 +16,17 @@ build() {(
|
||||||
export GOARCH="$ARCH"
|
export GOARCH="$ARCH"
|
||||||
sh_c go build -ldflags "-X lib/version.Version=$VERSION" \
|
sh_c go build -ldflags "-X lib/version.Version=$VERSION" \
|
||||||
-o "$BUILD_DIR/bin/d2" ./cmd/d2
|
-o "$BUILD_DIR/bin/d2" ./cmd/d2
|
||||||
)}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
VERSION="$(git_describe_ref)"
|
VERSION="$(git_describe_ref)"
|
||||||
BUILD_DIR="ci/release/build/$VERSION"
|
BUILD_DIR="ci/release/build/$VERSION"
|
||||||
|
|
||||||
|
|
||||||
runjob linux-amd64 'build linux amd64' &
|
runjob linux-amd64 'OS=linux ARCH=amd64 build linux amd64' &
|
||||||
runjob linux-arm64 'build linux arm64' &
|
runjob linux-arm64 'OS=linux ARCH=arm64 build linux arm64' &
|
||||||
runjob macos-amd64 'build macos amd64' &
|
runjob macos-amd64 'OS=macos ARCH=amd64 build macos amd64' &
|
||||||
runjob macos-arm64 'build macos arm64' &
|
runjob macos-arm64 'OS=macos ARCH=arm64 build macos arm64' &
|
||||||
wait_jobs
|
wait_jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,15 +102,22 @@ main() {
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
runjob 1_ensure_branch _1_ensure_branch
|
header '1_ensure_branch' && _1_ensure_branch
|
||||||
runjob 2_ensure_changelog _2_ensure_changelog
|
header '2_ensure_changelog' && _2_ensure_changelog
|
||||||
runjob 3_ensure_commit _3_ensure_commit
|
header '3_ensure_commit' && _3_ensure_commit
|
||||||
runjob 4_push_branch _4_push_branch
|
header '4_push_branch' && _4_push_branch
|
||||||
runjob 5_ensure_tag _5_ensure_tag
|
header '5_ensure_tag' && _5_ensure_tag
|
||||||
runjob 6_ensure_release _6_ensure_release
|
header '6_ensure_release' && _6_ensure_release
|
||||||
runjob 7_ensure_pr _7_ensure_pr
|
header '7_ensure_pr' && _7_ensure_pr
|
||||||
runjob 8_ensure_assets _8_ensure_assets
|
header '8_ensure_assets' && _8_ensure_assets
|
||||||
runjob 9_upload_assets _9_upload_assets
|
header '9_upload_assets' && _9_upload_assets
|
||||||
|
|
||||||
|
COLOR=2 header 'final steps'
|
||||||
|
cat <<EOF
|
||||||
|
1. Review and test the release: $release_url
|
||||||
|
2. Merge the PR: $pr_url
|
||||||
|
3. Publish the release!
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
_1_ensure_branch() {
|
_1_ensure_branch() {
|
||||||
|
|
@ -122,6 +129,7 @@ _1_ensure_branch() {
|
||||||
|
|
||||||
_2_ensure_changelog() {
|
_2_ensure_changelog() {
|
||||||
if [ -f "./ci/release/changelogs/$VERSION.md" ]; then
|
if [ -f "./ci/release/changelogs/$VERSION.md" ]; then
|
||||||
|
log "./ci/release/changelogs/$VERSION.md"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -134,7 +142,7 @@ _2_ensure_changelog() {
|
||||||
_3_ensure_commit() {
|
_3_ensure_commit() {
|
||||||
sh_c git add --all
|
sh_c git add --all
|
||||||
if [ "$(git show --no-patch --format=%s)" = "$VERSION" ]; then
|
if [ "$(git show --no-patch --format=%s)" = "$VERSION" ]; then
|
||||||
sh_c git commit --amend --no-edit
|
sh_c git commit --allow-empty --amend --no-edit
|
||||||
else
|
else
|
||||||
sh_c git commit --allow-empty -m "$VERSION"
|
sh_c git commit --allow-empty -m "$VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
@ -155,34 +163,37 @@ _5_ensure_tag() {
|
||||||
|
|
||||||
_6_ensure_release() {
|
_6_ensure_release() {
|
||||||
if gh release view "$VERSION" >/dev/null 2>&1; then
|
if gh release view "$VERSION" >/dev/null 2>&1; then
|
||||||
sh_c gh release edit \
|
release_url="$(sh_c gh release edit \
|
||||||
--draft \
|
--draft \
|
||||||
--notes-file "./ci/release/changelogs/$VERSION.md" \
|
--notes-file "./ci/release/changelogs/$VERSION.md" \
|
||||||
${PRERELEASE:+--prerelease} \
|
${PRERELEASE:+--prerelease} \
|
||||||
"--title=$VERSION" \
|
"--title=$VERSION" \
|
||||||
"$VERSION"
|
"$VERSION" | tee /dev/stderr)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
sh_c gh release create \
|
release_url="$(sh_c gh release create \
|
||||||
--draft \
|
--draft \
|
||||||
--notes-file "./ci/release/changelogs/$VERSION.md" \
|
--notes-file "./ci/release/changelogs/$VERSION.md" \
|
||||||
${PRERELEASE:+--prerelease} \
|
${PRERELEASE:+--prerelease} \
|
||||||
"--title=$VERSION" \
|
"--title=$VERSION" \
|
||||||
"$VERSION"
|
"$VERSION" | tee /dev/stderr)"
|
||||||
}
|
}
|
||||||
|
|
||||||
_7_ensure_pr() {
|
_7_ensure_pr() {
|
||||||
pr_url=$(gh pr view "$VERSION" --json=url '--template={{ .url }}' 2>/dev/null || true)
|
# We do not use gh pr view as that includes closed PRs.
|
||||||
|
pr_url="$(gh pr list --head "$VERSION" --json=url '--template={{ range . }}{{ .url }}{{end}}')"
|
||||||
|
body="Will be available at $(gh repo view --json=url '--template={{ .url }}')/releases/tag/$VERSION"
|
||||||
if [ -n "$pr_url" ]; then
|
if [ -n "$pr_url" ]; then
|
||||||
_echo "PR already exists: $pr_url"
|
sh_c gh pr edit --body "$body" "$VERSION"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
sh_c gh pr create --draft --fill
|
|
||||||
|
pr_url="$(sh_c gh pr create --fill --body "$body" | tee /dev/stderr)"
|
||||||
}
|
}
|
||||||
|
|
||||||
_8_ensure_assets() {
|
_8_ensure_assets() {
|
||||||
# ./ci/release/build.sh ${REBUILD:+--rebuild} $VERSION
|
# ./ci/release/build.sh ${REBUILD:+--rebuild} $VERSION
|
||||||
_echo TODO
|
log TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
_9_upload_assets() {
|
_9_upload_assets() {
|
||||||
|
|
|
||||||
2
ci/sub
2
ci/sub
|
|
@ -1 +1 @@
|
||||||
Subproject commit a4961f772d1f98bb7a8185a6590ed4346684e392
|
Subproject commit 3412fc4a998dd70e5d0de20a9bfb526023b093cc
|
||||||
Loading…
Reference in a new issue