-
Notifications
You must be signed in to change notification settings - Fork 117
75 lines (65 loc) · 2.22 KB
/
create-release-on-github.yml
File metadata and controls
75 lines (65 loc) · 2.22 KB
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
name: Create Release Notes
on:
workflow_dispatch:
workflow_call:
jobs:
create-release-notes:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Use Node.js
uses: actions/setup-node@v5
with:
node-version-file: '.nvmrc'
- name: 'Install dependencies'
run: npm ci
- name: Get version
id: get_version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').config.sdkVersion")
if git rev-parse "$CURRENT_VERSION" >/dev/null 2>&1; then
echo "Tag $CURRENT_VERSION already exists, nothing to do"
exit 0
else
echo "Tag $CURRENT_VERSION does not exist, proceeding with release creation"
fi
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Create release notes
uses: actions/github-script@v8
id: release_notes
with:
script: |
const currentVersion = '${{ steps.get_version.outputs.version }}';
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
base: 'main',
per_page: 100
});
const releasePr = prs.find(pr =>
pr.title === `Release ${currentVersion}` && pr.merged_at
);
if (!releasePr) {
core.setFailed(`No merged release PR found for version ${currentVersion}`);
return;
}
core.setOutput('notes', releasePr.body);
- name: Create GitHub Release
uses: actions/github-script@v8
with:
script: |
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ steps.get_version.outputs.version }}',
name: 'Release ${{ steps.get_version.outputs.version }}',
body: '${{ steps.release_notes.outputs.notes }}',
draft: false,
prerelease: false
});