-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update github release workflow with current pattern
Signed-off-by: Christopher Phillips <[email protected]>
- Loading branch information
Showing
10 changed files
with
260 additions
and
37 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,45 @@ | ||
name: "Bootstrap" | ||
description: "Bootstrap all tools and dependencies" | ||
inputs: | ||
go-version: | ||
description: "Go version to install" | ||
required: true | ||
default: "1.21.x" | ||
cache-key-prefix: | ||
description: "Prefix all cache keys with this value" | ||
required: true | ||
default: "831180ac25" | ||
bootstrap-apt-packages: | ||
description: "Space delimited list of tools to install via apt" | ||
default: "" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
|
||
- name: Restore tool cache | ||
id: tool-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ github.workspace }}/.tool | ||
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('Taskfile.yaml') }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('Taskfile.yaml') }} | ||
${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool | ||
- name: (cache-miss) Bootstrap project tools | ||
shell: bash | ||
run: make ci-bootstrap-tools | ||
|
||
- name: Bootstrap go dependencies | ||
shell: bash | ||
run: make ci-bootstrap-go | ||
|
||
- name: Install apt packages | ||
if: inputs.bootstrap-apt-packages != '' | ||
shell: bash | ||
run: | | ||
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo -E apt install -y ${{ inputs.bootstrap-apt-packages }} |
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 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
red=$(tput setaf 1) | ||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
# assert we are running in CI (or die!) | ||
if [[ -z "$CI" ]]; then | ||
echo "${bold}${red}This step should ONLY be run in CI. Exiting...${normal}" | ||
exit 1 | ||
fi |
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,2 +1,53 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
TOOL_DIR=.tool | ||
GH=$TOOL_DIR/gh | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
if ! [ -x "$(command -v $GH)" ]; then | ||
echo "The GitHub CLI could not be found." | ||
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 was deleted.
Oops, something went wrong.
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,78 @@ | ||
name: "Release" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: tag the latest commit on main with the given version (prefixed with v) | ||
required: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
FORCE_COLOR: true | ||
|
||
jobs: | ||
quality-gate: | ||
environment: release | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check if tag already exists | ||
# note: this will fail if the tag already exists | ||
run: | | ||
[[ "${{ 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 validations results | ||
uses: fountainhead/[email protected] | ||
id: validations | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
# This check name is defined as the github action job name (in .github/workflows/validations.yaml) | ||
checkName: "Validations" | ||
ref: ${{ github.event.pull_request.head.sha || github.sha }} | ||
|
||
- name: Quality gate | ||
if: steps.validations.outputs.conclusion != 'success' | ||
run: | | ||
echo "Validations Status: ${{ steps.validations.conclusion }}" | ||
false | ||
release: | ||
needs: [quality-gate] | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Bootstrap environment | ||
uses: ./.github/actions/bootstrap | ||
env: | ||
FORCE_COLOR: true | ||
|
||
- name: Tag release | ||
run: | | ||
git config user.name "anchoreci" | ||
git config user.email "[email protected]" | ||
git tag -a ${{ github.event.inputs.version }} -m "Release ${{ github.event.inputs.version }}" | ||
git push origin --tags | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build & publish release artifacts | ||
run: make ci-release | ||
env: | ||
# for mac signing and notarization... | ||
QUILL_SIGN_P12: ${{ secrets.ANCHORE_APPLE_DEVELOPER_ID_CERT_CHAIN }} | ||
QUILL_SIGN_PASSWORD: ${{ secrets.ANCHORE_APPLE_DEVELOPER_ID_CERT_PASS }} | ||
QUILL_NOTARY_ISSUER: ${{ secrets.APPLE_NOTARY_ISSUER }} | ||
QUILL_NOTARY_KEY_ID: ${{ secrets.APPLE_NOTARY_KEY_ID }} | ||
QUILL_NOTARY_KEY: ${{ secrets.APPLE_NOTARY_KEY }} | ||
# for creating the release (requires write access to packages and content) | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_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,29 @@ | ||
name: "Validations" | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
FORCE_COLOR: true | ||
|
||
jobs: | ||
|
||
Validations: | ||
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline | ||
name: "Validations" | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Bootstrap environment | ||
uses: ./.github/actions/bootstrap | ||
|
||
- name: Run all validations | ||
run: make pr-validations |
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