diff --git a/.github/workflows/add-lockdown-label.yml b/.github/workflows/add-lockdown-label.yml new file mode 100644 index 000000000000..33732b0381b6 --- /dev/null +++ b/.github/workflows/add-lockdown-label.yml @@ -0,0 +1,75 @@ +name: Add Branch Lockdown Label to PRs + +on: + pull_request_target: + workflow_dispatch: # Allows manual triggering of the workflow + +permissions: + actions: write # For managing the operation state cache + issues: write + +jobs: + add-label: + runs-on: ubuntu-latest + + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install jq + run: sudo apt-get install -y jq + + - name: Add label to PRs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Determine the third Tuesday of the current month + third_tuesday=$(date -d "$(date +%Y-%m-01) +14 days" +%Y-%m-%d) + while [ $(date -d "$third_tuesday" +%u) -ne 2 ]; do + third_tuesday=$(date -d "$third_tuesday + 1 day" +%Y-%m-%d) + done + + # Determine the first Tuesday of the current month + first_tuesday=$(date -d "$(date +%Y-%m-01)" +%Y-%m-%d) + while [ $(date -d "$first_tuesday" +%u) -ne 2 ]; do + first_tuesday=$(date -d "$first_tuesday + 1 day" +%Y-%m-%d) + done + + # Get current date + current_date=$(date +%Y-%m-%d) + + echo "Current Date: $current_date" + echo "Third Tuesday of the month: $third_tuesday" + echo "First Tuesday of the month: $first_tuesday" + + # Check if the current date is after the third Tuesday of this month or before the first Tuesday of this month + if [[ "$current_date" > "$third_tuesday" || "$current_date" < "$first_tuesday" ]]; then + echo "Within the label period. Checking if the branch matches..." + + # Get all open PRs targeting branches release/8* and release/9* excluding release/9.0.3xx + echo "Running gh pr list query..." + prs=$(gh pr list --state open --limit 200 --json number,baseRefName,author,labels) + echo "Total PRs Count: $(echo "$prs" | jq length)" + echo "PRs JSON: $prs" + + echo "Filtering PRs targeting release/8* and release/9* excluding release/9.0.3xx..." + prs_targeting_branches=$(echo "$prs" | jq '[.[] | select(.baseRefName | test("^release/[89].*")) | select(.baseRefName | test("^release/9.0.3xx") | not)]') + echo "Count of PRs targeting specific branches: $(echo "$prs_targeting_branches" | jq length)" + + echo "Filtering PRs without Branch Lockdown label..." + filtered_prs=$(echo "$prs_targeting_branches" | jq '[.[] | select(.labels | map(.name) | index("Branch Lockdown") | not) | .number]') + echo "Filtered PRs without Branch Lockdown label JSON: $filtered_prs" + echo "Count of Filtered PRs without Branch Lockdown label: $(echo "$filtered_prs" | jq length)" + + # Loop through filtered PRs and add label + for pr in $(echo "$filtered_prs" | jq -r '.[]'); do + echo "Adding label to PR #$pr" + gh pr edit $pr --add-label "Branch Lockdown" + done + else + echo "Outside the label period. No labels added." + fi diff --git a/documentation/project-docs/SDK-PR-guide.md b/documentation/project-docs/SDK-PR-guide.md index a3383460be79..04d7c65b171a 100644 --- a/documentation/project-docs/SDK-PR-guide.md +++ b/documentation/project-docs/SDK-PR-guide.md @@ -26,7 +26,7 @@ After the minor release locks down, it transitions into servicing / "QB" (Quarte ### Servicing releases The .NET SDK has monthly servicing releases (e.g.`7.0.100` VS `7.0.101`) aligning with the .NET Runtime servicing releases. These are for top fixes and security updates only to limit risk. Any servicing release is open for check-ins from the day the [branding PRs](https://github.com/dotnet/sdk/pulls?q=is%3Apr+branding) are merged (~1st of each month) and when code complete is (typically two weeks later). -The servicing branches are locked from the time of code complete to the next branding in case we need to respin any monthly release. Final signoffs are typically in the last week of each month. +The servicing branches are locked from the time of code complete to the next branding in case we need to respin any monthly release. We use the `Branch Lockdown` label to mark PRs that should go into the next servicing release but the branch is currently not open. Final signoffs are typically in the last week of each month. ### Schedule | Release Type | Frequency | Lockdown Release | Branch Open | Lockdown Date (estimate) | @@ -36,7 +36,7 @@ The servicing branches are locked from the time of code complete to the next bra | Servicing | Monthly | N/A | After branding, ~1st of the month | Third Tuesday of prior month (signoff is ~28th of each month) | ### Tactics approval -Even releases that are in lockdown can still take changes as long as they are approved and the final build isn't complete. To bring a change through tactics, mark it with the label servicing-consider and update the description to include 5 sections (Description, Customer Impact, Regression?, Risk, Testing). See previously approved bugs for examples by looking for the [servicing-approved](https://github.com/dotnet/sdk/pulls?q=is%3Apr+label%3AServicing-approved+is%3Aclosed) label. +Even releases that are in lockdown can still take changes as long as they are approved and the final build isn't complete. To bring a change through tactics, mark it with the label `servicing-consider` and update the description to include 5 sections (Description, Customer Impact, Regression?, Risk, Testing). See previously approved bugs for examples by looking for the [servicing-approved](https://github.com/dotnet/sdk/pulls?q=is%3Apr+label%3AServicing-approved+is%3Aclosed) label. ## External contributions External contributions are encouraged and welcome. There are so many teams working in this repo that it can be hard to track. Contributors looking to learn more about how to contribute should check out the [Developer Guide](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/developer-guide.md).