-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #683 from rgoldberg/682-release
Finish release overhaul
- Loading branch information
Showing
6 changed files
with
141 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/zsh -Ndefgku | ||
# | ||
# script/generate_token | ||
# mas | ||
# | ||
# Generates a GitHub App installation access token for GitHub Workflows. | ||
# | ||
|
||
. "${0:a:h}/_setup_script" | ||
|
||
header=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9 | ||
payload="${${$(printf '{"iss":%s,"iat":%s,"exp":%s}' "${TOKEN_APP_ID}" "$(("$(date +%s)" - 60))"\ | ||
"$(("$(date +%s)" + 540))" | base64)//[=$'\n']}//\/+/_-}" | ||
|
||
|
||
# shellcheck disable=SC1009,SC1036,SC1072,SC1073 | ||
curl\ | ||
-sX POST\ | ||
-H "Authorization: Bearer ${header}.${payload}.${${$(printf %s "${header}.${payload}" | | ||
openssl dgst -sha256 -sign =(printf %s "${TOKEN_APP_PRIVATE_KEY}") | base64)//[=$'\n']}//\/+/_-}"\ | ||
-H 'Accept: application/vnd.github+json'\ | ||
"https://api.github.com/app/installations/${TOKEN_APP_INSTALLATION_ID}/access_tokens" | | ||
jq -r .token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/zsh -Ndefgku | ||
# | ||
# script/release_cancel | ||
# mas | ||
# | ||
# Cancel a GitHub draft release. | ||
# | ||
# Usage: release_cancel <draft-release-tag> | ||
# | ||
|
||
. "${0:a:h}/_setup_script" | ||
|
||
tag="${1}" | ||
|
||
printf $'==> 🚀 Canceling release for tag %s\n\n' "${tag}" | ||
|
||
bump_url="$(gh release -R https://github.com/mas-cli/mas download "${tag}" -p bump.url -O - 2>/dev/null || true)" | ||
if [[ -n "${bump_url}" ]]; then | ||
gh pr close "${bump_url}" -d | ||
printf $'\n' | ||
else | ||
printf $'No custom tap formula bump PR URL found for draft release tag \'%s\'\n\n' "${tag}" | ||
fi | ||
|
||
gh release -R https://github.com/mas-cli/mas delete "${tag}" --cleanup-tag -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/zsh -Ndefgku | ||
# | ||
# script/release_start | ||
# mas | ||
# | ||
# Start the release process by creating & pushing a signed annotated version tag to the GitHub mas-cli/mas repo. | ||
# | ||
# Usage: release_start <version-tag-name> <version-title> [<version-ref>] | ||
# | ||
# <version-tag-name> must match the following zsh pattern: | ||
# | ||
# ^v[[:digit:]]+(\.[[:digit:]]+)*(-(alpha|beta|rc)\.[[:digit:]]+)?$ | ||
# | ||
# <version-title> must may contain at most 64 characters, which may be only visible characters or spaces | ||
# | ||
# <version-ref> if optional value supplied, must be on the main branch; defaults to HEAD | ||
# | ||
|
||
. "${0:a:h}/_setup_script" | ||
|
||
tag="${1}" | ||
title="${2}" | ||
ref="${3:-HEAD}" | ||
|
||
printf $'==> 🚀 Starting release for mas %s\n\n' "${tag#v}" | ||
|
||
if [[ ! "${tag}" =~ '^v[[:digit:]]+(\.[[:digit:]]+)*(-(alpha|beta|rc)\.[[:digit:]]+)?$' ]]; then | ||
printf $'\'%s\' is not a valid version tag\n' "${tag}" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ "${#title}" -gt 64 ]]; then | ||
printf $'\'%s\' is too long for a version title, which may contain at most 64 characters\n' "${title}" >&2 | ||
exit 2 | ||
fi | ||
|
||
if [[ "${title}" =~ [[:cntrl:]$'\t\n\r'] ]]; then | ||
printf $'\'%s\' is not a valid version title, which may contain only visible characters or spaces\n' "${title}" >&2 | ||
exit 3 | ||
fi | ||
|
||
# shellcheck disable=SC1009,SC1027,SC1036,SC1072,SC1073 | ||
if [[ "${title}" = (' '*|*' ') ]]; then | ||
printf $'\'%s\' is not a valid version title, which may not begin or end with a space\n' "${title}" >&2 | ||
exit 4 | ||
fi | ||
|
||
if ! git merge-base --is-ancestor "${ref}" upstream/main; then | ||
printf $'\'%s\' is not a valid reference for a version, which must be on the upstream/main branch\n' "${ref}" >&2 | ||
exit 5 | ||
fi | ||
|
||
git tag -s "${tag}" -m "${title}" "${ref}" | ||
|
||
printf $'Created version tag \'%s\' with title \'%s\' for \'%s\'\n\n' "${tag}" "${title}" "${ref}" | ||
|
||
git push upstream tag "${tag}" |