-
Notifications
You must be signed in to change notification settings - Fork 889
ci: Do release tagging in CI and add --draft support #5652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4fa5100
b7fc031
368786f
2449a80
c5a6ead
7381383
e538ec4
3b4ffa0
e211660
29a33be
e1c802b
7055b1d
9953d9b
cf2c523
61b6a90
2108056
c559c8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
# GitHub release workflow. | ||
name: release | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
inputs: | ||
increment: | ||
description: Preferred version increment (release script may promote e.g. patch to minor depending on changes). | ||
type: choice | ||
required: true | ||
default: patch | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
draft: | ||
description: Create a draft release (for manually editing release notes before publishing). | ||
type: boolean | ||
required: true | ||
snapshot: | ||
description: Force a dev version to be generated, implies dry_run. | ||
type: boolean | ||
|
@@ -25,9 +35,13 @@ permissions: | |
|
||
env: | ||
CODER_RELEASE: ${{ github.event.inputs.snapshot && 'false' || 'true' }} | ||
DRY_RUN: ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && 'true' || 'false' }} | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
release: | ||
name: Create and publish | ||
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }} | ||
env: | ||
# Necessary for Docker manifest | ||
|
@@ -45,6 +59,12 @@ jobs: | |
- name: Fetch git tags | ||
run: git fetch --tags --force | ||
|
||
# Configure git user name/email for creating annotated version tag. | ||
- name: Setup git config | ||
run: | | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "" | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v2 | ||
with: | ||
|
@@ -100,6 +120,38 @@ jobs: | |
AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }} | ||
AC_APIKEY_P8_BASE64: ${{ secrets.AC_APIKEY_P8_BASE64 }} | ||
|
||
- name: Create release tag and release notes | ||
run: | | ||
set -euo pipefail | ||
ref=HEAD | ||
old_version="$(git describe --abbrev=0 "$ref^1")" | ||
deansheather marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [[ $DRY_RUN == true ]]; then | ||
# Allow dry-run of branches to pass. | ||
export CODER_IGNORE_MISSING_COMMIT_METADATA=1 | ||
fi | ||
|
||
# Cache commit metadata. | ||
. ./scripts/release/check_commit_metadata.sh "$old_version" "$ref" | ||
|
||
# Create new release tag. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Is it possible to run the workflow for the same version twice? It happened to me a few times in the past that the release script broke down in the middle of releasing and I had to clean tags and artifacts manually before retrying. I'm curious if we need the safety mechanism here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good nit. I was thinking we can use the GH actions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To add to this, the ❯ git tag v0.14.2
❯ CI=1 ./scripts/release/tag_version.sh --ref HEAD --patch
Checking commit metadata for changes since v0.14.1...
No breaking changes detected, using "patch" increment.
Old version: v0.14.1
New version: v0.14.2
$ git tag -a v0.14.2 -m Release v0.14.2 f5d623ff
fatal: tag 'v0.14.2' already exists Does this, combined with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, although more convenient behavior is to allow for multiple runs to perform missing actions. For example, if the first run didn't publish the release notes due to HTTP 500, the second can fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean. I think that's fairly well addressed here since right now the critical part happens in "Publish release". If anything fails before the tag upload (GH release immediately follows), we can just restart the workflow. I just realized it's possible to run the workflow for a specific tag, not just for a branch. If we need to in the future it should be fairly easy to modify it to not error in I'll think about this some more, thanks for bringing it up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarifying! |
||
version="$( | ||
./scripts/release/tag_version.sh \ | ||
${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \ | ||
--ref "$ref" \ | ||
--${{ github.event.inputs.increment }} | ||
)" | ||
|
||
# Generate notes. | ||
release_notes_file="$(mktemp -t release_notes.XXXXXX)" | ||
./scripts/release/generate_release_notes.sh --old-version "$old_version" --new-version "$version" --ref "$ref" >> "$release_notes_file" | ||
echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> $GITHUB_ENV | ||
|
||
- name: Echo release notes | ||
run: | | ||
set -euo pipefail | ||
cat "$CODER_RELEASE_NOTES_FILE" | ||
|
||
- name: Build binaries | ||
run: | | ||
set -euo pipefail | ||
|
@@ -157,8 +209,11 @@ jobs: | |
|
||
- name: Publish release | ||
run: | | ||
set -euo pipefail | ||
./scripts/release/publish.sh \ | ||
${{ github.event.inputs.draft && '--draft' }} \ | ||
${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \ | ||
--release-notes-file "$CODER_RELEASE_NOTES_FILE" \ | ||
./build/*_installer.exe \ | ||
./build/*.zip \ | ||
./build/*.tar.gz \ | ||
|
@@ -195,6 +250,7 @@ jobs: | |
with: | ||
name: release-artifacts | ||
path: | | ||
./build/*_installer.exe | ||
./build/*.zip | ||
./build/*.tar.gz | ||
./build/*.tgz | ||
|
Uh oh!
There was an error while loading. Please reload this page.