Skip to content

Commit 5c719a8

Browse files
authored
Adds blocker to release if any issue has release-blocker label (#748)
Signed-off-by: Simon Davies <[email protected]>
1 parent 06267cd commit 5c719a8

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

.github/workflows/CreateRelease.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ permissions:
1313

1414
jobs:
1515

16+
release-blocker-check:
17+
# see https://github.com/orgs/community/discussions/26286#discussioncomment-3251208 for why we need to check the ref
18+
if: ${{ contains(github.ref, 'refs/heads/release/') }} || ${{ github.ref=='refs/heads/main' }}
19+
uses: ./.github/workflows/ReleaseBlockerCheck.yml
20+
with:
21+
repository: ${{ github.repository }}
22+
secrets: inherit
23+
1624
build-rust-ubuntu:
1725
# see https://github.com/orgs/community/discussions/26286#discussioncomment-3251208 for why we need to check the ref
1826
if: ${{ contains(github.ref, 'refs/heads/release/') }} || ${{ github.ref=='refs/heads/main' }}
1927
runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"]
28+
needs: [release-blocker-check]
2029

2130
steps:
2231
- uses: actions/checkout@v4
@@ -37,6 +46,7 @@ jobs:
3746
# see https://github.com/orgs/community/discussions/26286#discussioncomment-3251208 for why we need to check the ref
3847
if: ${{ contains(github.ref, 'refs/heads/release/') }} || ${{ github.ref=='refs/heads/main' }}
3948
runs-on: windows-2022
49+
needs: [release-blocker-check]
4050

4151
steps:
4252
- uses: actions/checkout@v4
@@ -56,6 +66,7 @@ jobs:
5666
build-guest-binaries:
5767
uses: ./.github/workflows/dep_build_guest_binaries.yml
5868
secrets: inherit
69+
needs: [release-blocker-check]
5970

6071
benchmarks:
6172
needs: [build-guest-binaries]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release Blocker Check
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
repository:
7+
description: "Repository to check in format 'owner/repo'"
8+
required: false
9+
type: string
10+
default: ${{ github.repository }}
11+
workflow_dispatch:
12+
inputs:
13+
repository:
14+
description: "Repository to check in format 'owner/repo'"
15+
required: false
16+
type: string
17+
18+
permissions:
19+
issues: read
20+
contents: read
21+
22+
jobs:
23+
check-blockers:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Check for Release Blocking Issues
29+
run: |
30+
REPO="${{ inputs.repository || github.repository }}"
31+
echo "Checking repository: $REPO"
32+
33+
if ! ./dev/check-release-blockers.sh "$REPO"; then
34+
echo "::error::Release blocked by open issues with 'release-blocker' label"
35+
exit 1
36+
fi
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release Blocker Cleanup
2+
3+
on:
4+
issues:
5+
types: [closed]
6+
7+
permissions:
8+
issues: write
9+
contents: read
10+
11+
jobs:
12+
remove-release-blocker:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Remove release-blocker label from closed issue
16+
run: |
17+
ISSUE_NUMBER=${{ github.event.issue.number }}
18+
echo "Checking if issue #$ISSUE_NUMBER has release-blocker label..."
19+
20+
# Check if the issue has the release-blocker label
21+
HAS_LABEL=$(gh issue view "$ISSUE_NUMBER" --json labels -q '.labels[] | select(.name == "release-blocker") | .name')
22+
23+
if [ -n "$HAS_LABEL" ]; then
24+
echo "✅ Issue #$ISSUE_NUMBER has release-blocker label, removing it..."
25+
gh issue edit "$ISSUE_NUMBER" --remove-label "release-blocker"
26+
echo "✅ Successfully removed release-blocker label from issue #$ISSUE_NUMBER"
27+
else
28+
echo "ℹ️ Issue #$ISSUE_NUMBER does not have release-blocker label, no action needed"
29+
fi
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

dev/check-release-blockers.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
set -u
4+
set -o pipefail
5+
6+
## DESCRIPTION:
7+
##
8+
## This script checks for open issues with the 'release-blocker' label
9+
## in a given GitHub repository. It exits with code 1 if any blocking
10+
## issues are found, or 0 if none are found.
11+
##
12+
## PRE-REQS:
13+
##
14+
## This script assumes that the gh cli is installed and in the PATH
15+
## and that there is a GitHub PAT in the GITHUB_TOKEN env var
16+
## with the following permissions:
17+
## - repo (read)
18+
## - issues (read)
19+
## or that the user is logged into the gh cli with an account with those permissions
20+
21+
22+
# Check if repository argument is provided
23+
if [ -z "${1:-}" ]; then
24+
echo "Error: Repository name not provided."
25+
echo "Usage: $0 <owner/repo>"
26+
echo "Example: $0 hyperlight-dev/hyperlight"
27+
exit 1
28+
fi
29+
30+
REPO="$1"
31+
echo "Checking for open issues with 'release-blocker' label in $REPO..."
32+
33+
# Extract owner and repo name from the argument
34+
OWNER=$(echo "$REPO" | cut -d'/' -f1)
35+
REPO_NAME=$(echo "$REPO" | cut -d'/' -f2)
36+
37+
# Get all open issues with release-blocker label
38+
BLOCKING_ISSUES=$(gh api graphql -f query='
39+
query($owner: String!, $repo: String!) {
40+
repository(owner: $owner, name: $repo) {
41+
issues(first: 100, states: OPEN, labels: ["release-blocker"]) {
42+
totalCount
43+
nodes {
44+
number
45+
title
46+
url
47+
}
48+
}
49+
}
50+
}' -f owner="$OWNER" -f repo="$REPO_NAME" --jq '.data.repository.issues')
51+
52+
BLOCKER_COUNT=$(echo "$BLOCKING_ISSUES" | jq '.totalCount')
53+
54+
if [ "$BLOCKER_COUNT" -gt 0 ]; then
55+
echo "❌ Found $BLOCKER_COUNT open release-blocking issue(s):"
56+
echo "$BLOCKING_ISSUES" | jq -r '.nodes[] | " - #\(.number): \(.title) (\(.url))"'
57+
echo ""
58+
echo "Release blocked by open issue(s) with 'release-blocker' label"
59+
exit 1
60+
else
61+
echo "✅ No open release blocking issues found"
62+
exit 0
63+
fi

docs/github-labels.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ In addition to lifecycle labels, we use the following labels to further categori
3939
- **good-first-issue** - The issue is suitable for new contributors or those looking for a simple task to start with.
4040
- **help-wanted** - The issue is a request for help or assistance.
4141
- **question** - The issue is a question or request for information.
42+
- **release-blocker** - Critical issues that must be resolved before the next release can be made. The presence of this label on any open issue will prevent releases being created by the release workflow
4243

4344
---
4445

@@ -56,4 +57,4 @@ In addition to **kind/*** labels, we use optional **area/*** labels to specify t
5657

5758

5859
## Notes
59-
This document is a work in progress and may be updated as needed. The labels and categories are subject to change based on the evolving needs of the project and community feedback.
60+
This document is a work in progress and may be updated as needed. The labels and categories are subject to change based on the evolving needs of the project and community feedback.

0 commit comments

Comments
 (0)