-
Notifications
You must be signed in to change notification settings - Fork 26
102 lines (97 loc) · 4.13 KB
/
ReleaseDrafter.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# This workflow automatically drafts new project releases so it is obvious
# what a current release will look like at any time.
#
# It takes advantage of the labels used in Project Mu to automatically categorize
# the types of changes in a given release. In addition, the semantic version of
# the code is constantly maintained based on Project Mu label conventions to ensure
# semantic versioning is followed and a release version is always ready.
#
# The workflow is set up to support three types of repos as used in Project Mu. The
# config file name varies depending on the branch being built.
#
# 1. A "latest release branch"
# - Example: `release/202405`
# - Config file: `release-draft-config-n.yml`
# 2. A "previous release branch"
# - Example: `release/202311`
# - Config file: `release-draft-config-n-1.yml`
# 3. A "main branch"
# - Example: `main`
# - Config file: `release-draft-config.yml`
#
# Note:
# - The versions for the above types of repos are automatically read from .sync/Version.njk.
# - The correct config files are automatically synced to the corresponding branches by the
# Mu DevOps file sync operation. No manual maintenance is needed.
#
# Project Mu repos are encouraged to use this reusable workflow if this release
# workflow makes sense in their repo.
#
# The release draft configuration is defined in:
# - .github/release-draft-config.yml
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
# For more information, see:
# https://github.com/release-drafter/release-drafter
name: Mu DevOps Release Draft Workflow
on:
workflow_call:
jobs:
update_release_draft:
name: Update Release Draft
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Download Version Information
id: download_ver_info
shell: bash
run: |
mkdir $HOME/temp
versionFileUrl="https://raw.githubusercontent.com/microsoft/mu_devops/main/.sync/Version.njk"
localFilePath=$HOME/temp/Version.njk
curl $versionFileUrl --output "${localFilePath}"
echo "file_path=${localFilePath}" >> $GITHUB_ENV
- name: Extract Version Information
id: extract_ver_info
shell: bash
env:
FILE_PATH: ${{ env.file_path }}
run: |
fileContent=$(cat "${FILE_PATH}")
latestMuReleaseBranch=$(echo "$fileContent" | grep -oP '(?<=latest_mu_release_branch = ").*(?=")')
previousMuReleaseBranch=$(echo "$fileContent" | grep -oP '(?<=previous_mu_release_branch = ").*(?=")')
echo "latest_mu_branch=${latestMuReleaseBranch}" >> $GITHUB_ENV
echo "latest_mu_branch_full=refs/heads/${latestMuReleaseBranch}" >> $GITHUB_ENV
echo "previous_mu_branch=${previousMuReleaseBranch}" >> $GITHUB_ENV
echo "previous_mu_branch_full=refs/heads/${previousMuReleaseBranch}" >> $GITHUB_ENV
- name: Build a ${{ env.latest_mu_branch }} Draft
if: ${{ startsWith(github.ref, env.latest_mu_branch_full) }}
id: update_draft_n
uses: release-drafter/release-drafter@v6.0.0
with:
# Note: Path is relative to .github/
config-name: release-draft-config-n.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build a ${{ env.previous_mu_branch }} Draft
if: ${{ startsWith(github.ref, env.previous_mu_branch_full) }}
id: update_draft_n_1
uses: release-drafter/release-drafter@v6.0.0
with:
# Note: Path is relative to .github/
config-name: release-draft-config-n-1.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build the New Release Draft
if: ${{ !startsWith(github.ref, 'refs/heads/release') }}
id: update_draft_non_release
uses: release-drafter/release-drafter@v6.0.0
with:
# Note: Path is relative to .github/
config-name: release-draft-config.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}