-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add release trigger Signed-off-by: Alex Goodman <[email protected]> * deduplicate version and changelog calls + add gh checks Signed-off-by: Alex Goodman <[email protected]> * add more chronicle verbosity, but not when triggering releases Signed-off-by: Alex Goodman <[email protected]> * bump chronicle version to get --version-file feature Signed-off-by: Alex Goodman <[email protected]> * update bootstrap tool workflow to include glow Signed-off-by: Alex Goodman <[email protected]> * add version prefix check on tags in release quality gate Signed-off-by: Alex Goodman <[email protected]> --------- Signed-off-by: Alex Goodman <[email protected]>
- Loading branch information
Showing
6 changed files
with
113 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
if ! [ -x "$(command -v gh)" ]; then | ||
echo "The GitHub CLI could not be found. To continue follow the instructions at https://github.com/cli/cli#installation" | ||
exit 1 | ||
fi | ||
|
||
gh auth status | ||
|
||
# we need all of the git state to determine the next version. Since tagging is done by | ||
# the release pipeline it is possible to not have all of the tags from previous releases. | ||
git fetch --tags | ||
|
||
# populates the CHANGELOG.md and VERSION files | ||
echo "${bold}Generating changelog...${normal}" | ||
make changelog 2> /dev/null | ||
|
||
NEXT_VERSION=$(cat VERSION) | ||
|
||
if [[ "$NEXT_VERSION" == "" || "${NEXT_VERSION}" == "(Unreleased)" ]]; then | ||
echo "Could not determine the next version to release. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
while true; do | ||
read -p "${bold}Do you want to trigger a release for version '${NEXT_VERSION}'?${normal} [y/n] " yn | ||
case $yn in | ||
[Yy]* ) echo; break;; | ||
[Nn]* ) echo; echo "Cancelling release..."; exit;; | ||
* ) echo "Please answer yes or no.";; | ||
esac | ||
done | ||
|
||
echo "${bold}Kicking off release for ${NEXT_VERSION}${normal}..." | ||
echo | ||
gh workflow run release.yaml -f version=${NEXT_VERSION} | ||
|
||
echo | ||
echo "${bold}Waiting for release to start...${normal}" | ||
sleep 10 | ||
|
||
set +e | ||
|
||
echo "${bold}Head to the release workflow to monitor the release:${normal} $(gh run list --workflow=release.yaml --limit=1 --json url --jq '.[].url')" | ||
id=$(gh run list --workflow=release.yaml --limit=1 --json databaseId --jq '.[].databaseId') | ||
gh run watch $id --exit-status || (echo ; echo "${bold}Logs of failed step:${normal}" && GH_PAGER="" gh run view $id --log-failed) |
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
name: "Release" | ||
on: | ||
push: | ||
# take no actions on push to any branch... | ||
branches-ignore: | ||
- "**" | ||
# ... only act on release tags | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: tag the latest commit on main with the given version (prefixed with v) | ||
required: true | ||
|
||
env: | ||
GO_VERSION: "1.19.x" | ||
|
@@ -18,12 +16,11 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# we don't want to release commits that have been pushed and tagged, but not necessarily merged onto main | ||
- name: Ensure tagged commit is on main | ||
- name: Check if tag already exists | ||
# note: this will fail if the tag already exists | ||
run: | | ||
echo "Tag: ${GITHUB_REF##*/}" | ||
git fetch origin main | ||
git merge-base --is-ancestor ${GITHUB_REF##*/} origin/main && echo "${GITHUB_REF##*/} is a commit on main!" | ||
[[ "${{ github.event.inputs.version }}" == v* ]] || (echo "version '${{ github.event.inputs.version }}' does not have a 'v' prefix" && exit 1) | ||
git tag ${{ github.event.inputs.version }} | ||
- name: Check static analysis results | ||
uses: fountainhead/[email protected] | ||
|
@@ -120,6 +117,13 @@ jobs: | |
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Tag release | ||
run: | | ||
git tag ${{ github.event.inputs.version }} | ||
git push origin --tags | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build & publish release artifacts | ||
run: make release | ||
env: | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
CHANGELOG.md | ||
VERSION | ||
/test/results | ||
/dist | ||
/snapshot | ||
|
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