Skip to content

Commit b82a782

Browse files
authored
chore(scripts): implement mainline and stable release channels (coder#13048)
Fixes coder#12458
1 parent a6af7a5 commit b82a782

File tree

7 files changed

+539
-148
lines changed

7 files changed

+539
-148
lines changed

.github/workflows/release.yaml

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# GitHub release workflow.
22
name: Release
33
on:
4-
push:
5-
tags:
6-
- "v*"
74
workflow_dispatch:
85
inputs:
6+
release_channel:
7+
type: choice
8+
description: Release channel
9+
options:
10+
- mainline
11+
- stable
12+
release_notes:
13+
description: Release notes for the publishing the release. This is required to create a release.
914
dry_run:
1015
description: Perform a dry-run release (devel). Note that ref must be an annotated tag when run without dry-run.
1116
type: boolean
@@ -28,6 +33,8 @@ env:
2833
# https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
2934
CODER_RELEASE: ${{ !inputs.dry_run }}
3035
CODER_DRY_RUN: ${{ inputs.dry_run }}
36+
CODER_RELEASE_CHANNEL: ${{ inputs.release_channel }}
37+
CODER_RELEASE_NOTES: ${{ inputs.release_notes }}
3138

3239
jobs:
3340
release:
@@ -62,21 +69,45 @@ jobs:
6269
echo "CODER_FORCE_VERSION=$version" >> $GITHUB_ENV
6370
echo "$version"
6471
65-
- name: Create release notes
66-
env:
67-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68-
# We always have to set this since there might be commits on
69-
# main that didn't have a PR.
70-
CODER_IGNORE_MISSING_COMMIT_METADATA: "1"
72+
# Verify that all expectations for a release are met.
73+
- name: Verify release input
74+
if: ${{ !inputs.dry_run }}
75+
run: |
76+
set -euo pipefail
77+
78+
if [[ "${GITHUB_REF}" != "refs/tags/v"* ]]; then
79+
echo "Ref must be a semver tag when creating a release, did you use scripts/release.sh?"
80+
exit 1
81+
fi
82+
83+
# 2.10.2 -> release/2.10
84+
version="$(./scripts/version.sh)"
85+
release_branch=release/${version%.*}
86+
branch_contains_tag=$(git branch --remotes --contains "${GITHUB_REF}" --list "*/${release_branch}" --format='%(refname)')
87+
if [[ -z "${branch_contains_tag}" ]]; then
88+
echo "Ref tag must exist in a branch named ${release_branch} when creating a release, did you use scripts/release.sh?"
89+
exit 1
90+
fi
91+
92+
if [[ -z "${CODER_RELEASE_NOTES}" ]]; then
93+
echo "Release notes are required to create a release, did you use scripts/release.sh?"
94+
exit 1
95+
fi
96+
97+
echo "Release inputs verified:"
98+
echo
99+
echo "- Ref: ${GITHUB_REF}"
100+
echo "- Version: ${version}"
101+
echo "- Release channel: ${CODER_RELEASE_CHANNEL}"
102+
echo "- Release branch: ${release_branch}"
103+
echo "- Release notes: true"
104+
105+
- name: Create release notes file
71106
run: |
72107
set -euo pipefail
73-
ref=HEAD
74-
old_version="$(git describe --abbrev=0 "$ref^1")"
75-
version="v$(./scripts/version.sh)"
76108
77-
# Generate notes.
78109
release_notes_file="$(mktemp -t release_notes.XXXXXX)"
79-
./scripts/release/generate_release_notes.sh --check-for-changelog --old-version "$old_version" --new-version "$version" --ref "$ref" >> "$release_notes_file"
110+
echo "$CODER_RELEASE_NOTES" > "$release_notes_file"
80111
echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> $GITHUB_ENV
81112
82113
- name: Show release notes
@@ -265,6 +296,9 @@ jobs:
265296
set -euo pipefail
266297
267298
publish_args=()
299+
if [[ $CODER_RELEASE_CHANNEL == "stable" ]]; then
300+
publish_args+=(--stable)
301+
fi
268302
if [[ $CODER_DRY_RUN == *t* ]]; then
269303
publish_args+=(--dry-run)
270304
fi

0 commit comments

Comments
 (0)