Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ on:
pull_request:
types: [closed]
branches: [main]
workflow_dispatch:
inputs:
bump_type:
description: Version bump to apply
required: true
type: choice
options:
- patch
- minor
- major

permissions:
contents: read
Expand All @@ -16,23 +26,35 @@ jobs:
check-release-label:
name: Check for release label
if: |
github.event.pull_request.merged == true
&& contains(github.event.pull_request.labels.*.name, 'release')
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'release'))
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.check.outputs.should-release }}
bump-type: ${{ steps.check.outputs.bump-type }}
steps:
- name: Check release conditions
id: check
env:
EVENT_NAME: ${{ github.event_name }}
BUMP_TYPE: ${{ inputs.bump_type }}
HAS_BUMP_MAJOR: ${{ contains(github.event.pull_request.labels.*.name, 'bump-major') }}
HAS_BUMP_MINOR: ${{ contains(github.event.pull_request.labels.*.name, 'bump-minor') }}
HAS_BUMP_PATCH: ${{ contains(github.event.pull_request.labels.*.name, 'bump-patch') }}
run: |
if ${{ contains(github.event.pull_request.labels.*.name, 'bump-major') }}; then
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "bump-type=$BUMP_TYPE" >> "$GITHUB_OUTPUT"
echo "should-release=true" >> "$GITHUB_OUTPUT"
echo "Manual release requested with bump type '$BUMP_TYPE'"
elif [ "$HAS_BUMP_MAJOR" = "true" ]; then
echo "bump-type=major" >> "$GITHUB_OUTPUT"
echo "should-release=true" >> "$GITHUB_OUTPUT"
elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-minor') }}; then
elif [ "$HAS_BUMP_MINOR" = "true" ]; then
echo "bump-type=minor" >> "$GITHUB_OUTPUT"
echo "should-release=true" >> "$GITHUB_OUTPUT"
elif ${{ contains(github.event.pull_request.labels.*.name, 'bump-patch') }}; then
elif [ "$HAS_BUMP_PATCH" = "true" ]; then
echo "bump-type=patch" >> "$GITHUB_OUTPUT"
echo "should-release=true" >> "$GITHUB_OUTPUT"
else
Expand Down Expand Up @@ -191,8 +213,10 @@ jobs:
id: check-rejection
env:
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY_NAME: ${{ github.repository }}
GITHUB_RUN_ID_VALUE: ${{ github.run_id }}
run: |
RESPONSE=$(gh api /repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/approvals)
RESPONSE=$(gh api "/repos/$GITHUB_REPOSITORY_NAME/actions/runs/$GITHUB_RUN_ID_VALUE/approvals")
REJECTED=$(echo "$RESPONSE" | jq '[.[] | select(.state == "rejected")] | length')
if [ "$REJECTED" -gt 0 ]; then
echo "was_rejected=true" >> "$GITHUB_OUTPUT"
Expand Down
13 changes: 7 additions & 6 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Releasing

Releases are driven by PR labels. When a PR with the right labels is merged to `main`, a GitHub Actions workflow handles version bumping, tagging, creating a GitHub Release (with auto-generated notes), and publishing to NuGet.
Releases are usually driven by PR labels. When a PR with the right labels is merged to `main`, a GitHub Actions workflow handles version bumping, tagging, creating a GitHub Release (with auto-generated notes), and publishing to NuGet. You can also trigger the `Release` workflow manually from GitHub Actions and choose the bump type.

## Release Process

1. Add the `release` label and exactly one of `bump-patch`, `bump-minor`, or `bump-major` to your PR
2. Merge the PR to `main`
3. Approve the release in the GitHub Environment gate (the workflow pauses for maintainer approval)
4. The workflow bumps the version in `Directory.Build.props`, commits to `main`, creates a git tag, and creates a GitHub Release
5. The GitHub Release triggers the [`main.yaml`](.github/workflows/main.yaml) workflow, which builds and publishes the packages to NuGet
1. Either:
- add the `release` label and exactly one of `bump-patch`, `bump-minor`, or `bump-major` to your PR, then merge it to `main`, or
- open the `Release` workflow in GitHub Actions, click **Run workflow**, and choose `patch`, `minor`, or `major`
2. Approve the release in the GitHub Environment gate (the workflow pauses for maintainer approval)
3. The workflow bumps the version in `Directory.Build.props`, commits to `main`, creates a git tag, and creates a GitHub Release
4. The GitHub Release triggers the [`main.yaml`](.github/workflows/main.yaml) workflow, which builds and publishes the packages to NuGet
Loading