-
Notifications
You must be signed in to change notification settings - Fork 113
114 lines (98 loc) · 4.84 KB
/
generate-release-notes.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
103
104
105
106
107
108
109
110
111
112
113
114
name: 'Generate release notes'
run-name: '[${{ github.ref_name }}] Generate release notes (test: ${{ inputs.test_run }})'
on:
workflow_dispatch:
inputs:
test_run:
description: 'Test run?'
required: true
type: boolean
permissions: {}
jobs:
generate-release-notes:
name: 'Generate release notes'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout release branch
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
with:
persist-credentials: false
fetch-depth: 0 # Fetch the entire repo for the below git commit graph operations
- name: Calculate release information
run: |
git fetch --tags
# Grab the latest tag from the current branch. If it doesn't exist, grab the latest tag across all branches.
last_release_tag=$(git describe --tags --abbrev=0 || git describe --tags $(git rev-list --tags --max-count=1))
echo "Using tag: $last_release_tag"
last_release_date=$(git log -1 --format=%aI "$last_release_tag")
echo "last_release_date=$last_release_date" >> $GITHUB_ENV
versionFile="./eng/Versions.props"
release_version=$(perl -ne '/<VersionPrefix>([^<]*)/ && print $1' $versionFile)
release_version_label=$(perl -ne '/<PreReleaseVersionLabel>([^<]*)/ && print $1' $versionFile)
major_minor_version=${release_version%.*}
if [[ "$TEST_RUN" == "true" ]]; then
qualified_release_version="test-$release_version"
else
version_url="https://aka.ms/dotnet/diagnostics/monitor${major_minor_version}/release/dotnet-monitor.version"
qualified_release_version=$(curl -sL $version_url)
# Check if the aka.ms url existed
if [[ "$qualified_release_version" =~ "<html" || -z "$qualified_release_version" ]]; then
echo "Could not determine qualified release version, $version_url did not contain the expected information"
exit 1
fi
# trim the return carriage
qualified_release_version=$(echo $qualified_release_version | tr -d '\r')
fi
friendly_release_name=""
if [ "$release_version_label" == "rtm" ] || [ "$release_version_label" == "servicing" ]; then
friendly_release_name="$release_version build"
elif [ "$release_version_label" == "rc" ]; then
friendly_release_name="official $release_version Release Candidate"
else
friendly_release_name="next official preview version"
fi
release_note_path="./documentation/releaseNotes/releaseNotes.v${qualified_release_version}.md"
echo "release_note_path=$release_note_path" >> $GITHUB_ENV
echo "friendly_release_name=$friendly_release_name" >> $GITHUB_ENV
echo "qualified_release_version=$qualified_release_version" >> $GITHUB_ENV
env:
TEST_RUN: ${{ inputs.test_run }}
- name: Checkout main
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
with:
persist-credentials: true # We need to persist credentials to push the resulting changes upstream.
ref: main
- name: Generate release notes
uses: ./.github/actions/generate-release-notes
with:
output: ${{ env.release_note_path }}
last_release_date: ${{ env.last_release_date }}
build_description: ${{ env.friendly_release_name }}
auth_token: ${{ secrets.GITHUB_TOKEN }}
branch_name: ${{ github.ref_name }}
- name: Open PR (test run)
if: ${{ inputs.test_run }}
uses: ./.github/actions/open-pr
with:
draft: true
files_to_commit: ${{ env.release_note_path }}
title: "[test] Add ${{ env.qualified_release_version }} release notes"
commit_message: generate release notes
body: This is a test PR. Add ${{ env.qualified_release_version }} release notes. This PR was auto generated and will not be automatically merged in.
branch_name: releaseNotes/test/${{ env.qualified_release_version }}
fail_if_files_unchanged: true
auth_token: ${{ secrets.GITHUB_TOKEN }}
- name: Open PR
if: ${{ !inputs.test_run }}
uses: ./.github/actions/open-pr
with:
files_to_commit: ${{ env.release_note_path }}
title: "Add ${{ env.qualified_release_version }} release notes"
commit_message: generate release notes
body: Add ${{ env.qualified_release_version }} release notes. This PR was auto generated and will not be automatically merged in.
branch_name: releaseNotes/${{ env.qualified_release_version }}
fail_if_files_unchanged: true
auth_token: ${{ secrets.GITHUB_TOKEN }}