Skip to content

Commit fe4cd76

Browse files
committed
Create draft-release.yml
1 parent 1075758 commit fe4cd76

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Draft Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- src/manifest.json
9+
10+
jobs:
11+
get-version-if-new:
12+
name: Get Version (if new)
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.get-new-version-step.outputs.result }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/github-script@v7
19+
id: get-new-version-step
20+
with:
21+
script: |
22+
const fs = require('node:fs');
23+
const { version } = JSON.parse(fs.readFileSync(('${{ github.workspace }}/src/manifest.json')));
24+
const releases = await github.paginate(github.rest.repos.listReleases, { owner: context.repo.owner, repo: context.repo.repo, });
25+
if (releases.every(({ tag_name }) => tag_name !== `v${version}`)) {
26+
return version;
27+
}
28+
return '';
29+
result-encoding: string
30+
31+
draft-release:
32+
name: Draft Release
33+
needs: [get-version-if-new]
34+
if: needs.get-version-if-new.outputs.version != ''
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: write
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
44+
- name: Create release notes
45+
run: dev/release-notes.sh
46+
47+
- name: Create Github release draft
48+
id: create-draft
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
name: ${{ needs.get-version-if-new.outputs.version }}
52+
tag_name: v${{ needs.get-version-if-new.outputs.version }}
53+
body_path: release-notes.md
54+
draft: true
55+
56+
- run: >
57+
echo "Created draft: ${{ steps.create-draft.outputs.url }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)