Skip to content

Commit 9ee7726

Browse files
committed
Add N, N-1, and main branch release drafting
Updates the `ReleaseDrafter.yml` workflow to filter the base ref to use when composing the release draft based on the GitHub trigger context. This allows simultaneous release drafting in repos that use release branches while repos with non-release branches (e.g. main branch) are not impacted. Adds a variable to `Version.njk` to track the previous Mu release branch name. This files continues to serve as a single location where the release branches are defined. Updates the file sync process to sync the release drafter config file as needed for the corresponding repo. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
1 parent e035e8d commit 9ee7726

4 files changed

Lines changed: 85 additions & 4 deletions

File tree

.github/workflows/ReleaseDrafter.yml

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
# the code is constantly maintained based on Project Mu label conventions to ensure
77
# semantic versioning is followed and a release version is always ready.
88
#
9+
# The workflow is set up to support three types of repos as used in Project Mu. The
10+
# config file name varies depending on the branch being built.
11+
#
12+
# 1. A "latest release branch"
13+
# - Example: `release/202302`
14+
# - Config file: `release-draft-config-n.yml`
15+
# 2. A "previous release branch"
16+
# - Example: `release/202208`
17+
# - Config file: `release-draft-config-n-1.yml`
18+
# 3. A "main branch"
19+
# - Example: `main`
20+
# - Config file: `release-draft-config.yml`
21+
#
22+
# Note:
23+
# - The versions for the above types of repos are automatically read from .sync/Version.njk.
24+
# - The correct config files are automatically synced to the corresponding branches by the
25+
# Mu DevOps file sync operation. No manual maintenance is needed.
26+
#
927
# Project Mu repos are encouraged to use this reusable workflow if this release
1028
# workflow makes sense in their repo.
1129
#
@@ -29,8 +47,51 @@ jobs:
2947
runs-on: ubuntu-latest
3048

3149
steps:
50+
- name: Download Version Information
51+
if: ${{ startsWith(github.ref, 'refs/heads/release') }}
52+
id: download_ver_info
53+
shell: bash
54+
run: |
55+
mkdir $HOME/temp
56+
versionFileUrl="https://raw.githubusercontent.com/microsoft/mu_devops/main/.sync/Version.njk"
57+
localFilePath=$HOME/temp/Version.njk
58+
curl $versionFileUrl --output "${localFilePath}"
59+
echo "file_path=${localFilePath}" >> $GITHUB_ENV
60+
- name: Extract Version Information
61+
if: ${{ startsWith(github.ref, 'refs/heads/release') }}
62+
id: extract_ver_info
63+
shell: bash
64+
env:
65+
FILE_PATH: ${{ env.file_path }}
66+
run: |
67+
fileContent=$(cat "${FILE_PATH}")
68+
latestMuReleaseBranch=$(echo "$fileContent" | grep -oP '(?<=latest_mu_release_branch = ").*(?=")')
69+
previousMuReleaseBranch=$(echo "$fileContent" | grep -oP '(?<=previous_mu_release_branch = ").*(?=")')
70+
echo "latest_mu_branch=${latestMuReleaseBranch}" >> $GITHUB_ENV
71+
echo "latest_mu_branch_full=refs/heads/${latestMuReleaseBranch}" >> $GITHUB_ENV
72+
echo "previous_mu_branch=${previousMuReleaseBranch}" >> $GITHUB_ENV
73+
echo "previous_mu_branch_full=refs/heads/${previousMuReleaseBranch}" >> $GITHUB_ENV
74+
- name: Build a ${{ env.latest_mu_branch }} Draft
75+
if: ${{ startsWith(github.ref, env.latest_mu_branch_full) }}
76+
id: update_draft_n
77+
uses: release-drafter/release-drafter@v5.23.0
78+
with:
79+
# Note: Path is relative to .github/
80+
config-name: release-draft-config-n.yml
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
- name: Build a ${{ env.previous_mu_branch }} Draft
84+
if: ${{ startsWith(github.ref, env.previous_mu_branch_full) }}
85+
id: update_draft_n_1
86+
uses: release-drafter/release-drafter@v5.23.0
87+
with:
88+
# Note: Path is relative to .github/
89+
config-name: release-draft-config-n-1.yml
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3292
- name: Build the New Release Draft
33-
id: update_draft
93+
if: ${{ !startsWith(github.ref, 'refs/heads/release') }}
94+
id: update_draft_non_release
3495
uses: release-drafter/release-drafter@v5.23.0
3596
with:
3697
# Note: Path is relative to .github/

.sync/Files.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ group:
441441
trigger_branch_name: 'main'
442442
- source: .sync/workflows/config/release-draft/release-draft-config.yml
443443
dest: .github/release-draft-config.yml
444+
template: true
444445
repos: |
445446
microsoft/mu_devops
446447
microsoft/mu_feature_config
@@ -451,14 +452,22 @@ group:
451452
microsoft/mu_tiano_platforms
452453
453454
# Leaf Workflow - Release Draft
454-
# Note: The default branch name used to draft releases on in this group is
455-
# the latest Mu release branch (e.g. "release/202302")
455+
# Note: This group has two files synced that allow separate configuration for
456+
# n (e.g. "release/202302") and n-1 (e.g. "release/202208") branches.
456457
- files:
457458
- source: .sync/workflows/leaf/release-draft.yml
458459
dest: .github/workflows/release-draft.yml
459460
template: true
460461
- source: .sync/workflows/config/release-draft/release-draft-config.yml
461-
dest: .github/release-draft-config.yml
462+
dest: .github/release-draft-config-n.yml
463+
template:
464+
latest: true
465+
release_branch: true
466+
- source: .sync/workflows/config/release-draft/release-draft-config.yml
467+
dest: .github/release-draft-config-n-1.yml
468+
template:
469+
latest: false
470+
release_branch: true
462471
repos: |
463472
microsoft/mu_basecore
464473
microsoft/mu_common_intel_min_platform

.sync/Version.njk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
{# The latest Project Mu release branch value. #}
3636
{% set latest_mu_release_branch = "release/202302" %}
37+
{% set previous_mu_release_branch = "release/202208" %}
3738

3839
{# The version of the ubuntu-22-build container to use. #}
3940
{% set linux_build_container = "ghcr.io/microsoft/mu_devops/ubuntu-22-build:bc713a5" %}

.sync/workflows/config/release-draft/release-draft-config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@
1717
# For more information, see:
1818
# https://github.com/release-drafter/release-drafter
1919

20+
{% import '../../../Version.njk' as sync_version -%}
21+
2022
name-template: 'v$RESOLVED_VERSION'
2123
tag-template: 'v$RESOLVED_VERSION'
2224

25+
{# `release_branch` applies a commitish. `latest` then determines the branch to use. -#}
26+
{# If a commitish is not specified, then the `github.ref` value is implicitly used. -#}
27+
{%- if release_branch %}
28+
{% set release_branch = "refs/heads/" + (sync_version.latest_mu_release_branch if latest else sync_version.previous_mu_release_branch) %}
29+
commitish: {{ release_branch }}
30+
filter-by-commitish: true
31+
{% endif %}
32+
2333
template: |
2434
# What's Changed
2535

0 commit comments

Comments
 (0)