-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (47 loc) · 1.61 KB
/
draft-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
name: Draft Release
on:
push:
branches:
- main
jobs:
draft-release:
name: Draft Github Release
runs-on: ubuntu-20.04
steps:
- name: Draft github release
uses: actions/github-script@v6
with:
script: |
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
})
const filtered = releases.data.filter(release => release.draft == true && release.tag_name === 'unreleased');
if (filtered.length === 0) {
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
} else {
console.log("Deleting old untagged release")
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: filtered[0].id
})
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
}