-
Notifications
You must be signed in to change notification settings - Fork 115
137 lines (116 loc) · 4.79 KB
/
post-release.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
run-name: '[${{ github.ref_name }}] Post release'
on:
release: # Run on every release to add new version information.
types: [released]
# Only process one release at a time so we can generate cumulative results in the same PR.
# NOTE: This is currently restricted to only having 2 releases at the exact same time, any more and
# the pending jobs will be cancelled (but can be manually re-invoked).
concurrency:
group: post-release-workflow
cancel-in-progress: false
env:
BASE_BRANCH: main
TARGET_BRANCH_POSTFIX: release-info/on-release
permissions: {}
jobs:
calculate-supported-frameworks:
name: 'Calculated supported frameworks'
runs-on: ubuntu-latest
outputs:
result: ${{ steps.scan.outputs.supported_frameworks }}
# Spin a managed build and analyze the output to determine the supported frameworks for a given commit.
# It's simpler than trying to parse our `eng/Versions.prop` due to the conditionals in it.
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
persist-credentials: false
- name: Build
id: build
run: |
./build.sh -ci -c Release -skipnative
- name: Scan supported frameworks
id: scan
run: |
supported_frameworks=$(ls ./artifacts/bin/dotnet-monitor/Release | grep "net" | xargs)
echo "supported_frameworks=$supported_frameworks" >> "$GITHUB_OUTPUT"
ensure-target-ref-exists:
name: 'Ensure target ref exists'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
persist-credentials: false
# To avoid permission issues, create the target ref we will be updating
# using GitHub APIs.
#
# Also check if there's an existing PR open from our target ref.
# If so, multiple releases have occurred in the same time span
# and we want to update that PR.
#
- name: Ensure target ref exists
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
retries: 3
script: |
const branchName = `bot/${process.env.TARGET_BRANCH_POSTFIX}`;
const prs = await github.paginate(github.rest.pulls.list, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${branchName}`,
base: process.env.BASE_BRANCH
});
if (prs !== undefined && prs.length > 0) {
return;
}
const baseRefName = `heads/${process.env.BASE_BRANCH}`
const baseRef = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: baseRefName
});
const createOrUpdateRef = require('./.github/actions/gh-script-utils/create-or-update-ref.js');
await createOrUpdateRef(github, context, baseRef.data.object.sha, branchName);
register-release-information:
name: 'Register new release'
needs: [calculate-supported-frameworks, ensure-target-ref-exists]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
discussions: write
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
persist-credentials: true # We need to persist credentials inorder to open a PR.
ref: bot/${{ env.TARGET_BRANCH_POSTFIX }}
- name: Update releases.json
uses: ./.github/actions/update-releases-json
with:
auth_token: ${{ secrets.GITHUB_TOKEN }}
releases_json_file: ./.github/releases.json
end_of_support_discussion_category: Announcements
supported_frameworks: ${{needs.calculate-supported-frameworks.outputs.result}}
- name: Update releases.md
uses: ./.github/actions/update-releases-md
with:
releases_json_file: ./.github/releases.json
releases_md_file: ./documentation/releases.md
- name: Open PR
uses: ./.github/actions/open-pr
with:
files_to_commit: ./.github/releases.json ./documentation/releases.md
title: "Register new release information"
commit_message: Register ${{ github.ref_name }} release information
body: Register new release information.
branch_name: ${{ env.TARGET_BRANCH_POSTFIX }}
base_branch: ${{ env.BASE_BRANCH }}
labels: automatic-pr
fail_if_files_unchanged: true # If we're responding to a release, we must have updates.
update_if_already_exists: true
auth_token: ${{ secrets.GITHUB_TOKEN }}