-
Notifications
You must be signed in to change notification settings - Fork 3
73 lines (65 loc) · 2.27 KB
/
dev-draft-release.yml
File metadata and controls
73 lines (65 loc) · 2.27 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
name: Dev Draft Release
on:
workflow_run:
workflows: ["CI"]
types: [completed]
jobs:
draft-release:
name: Create/Update Dev Draft Release
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'dev'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout dev commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
submodules: recursive
- name: Compute dev tag
id: tag
run: |
BASE_VERSION=$(node -p "require('./package.json').version")
DEV_SUFFIX="dev.${{ github.event.workflow_run.run_number }}"
DEV_TAG="v${BASE_VERSION}-${DEV_SUFFIX}"
echo "base_version=${BASE_VERSION}" >> "$GITHUB_OUTPUT"
echo "dev_tag=${DEV_TAG}" >> "$GITHUB_OUTPUT"
- name: Remove previous dev draft releases
uses: actions/github-script@v7
with:
script: |
const releases = await github.paginate(github.rest.repos.listReleases, {
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
});
for (const release of releases) {
const isDevTag = /-dev\.\d+$/.test(release.tag_name || "");
if (isDevTag && release.draft) {
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
});
}
}
- name: Remove previous dev tags
env:
GH_TOKEN: ${{ github.token }}
run: |
for tag in $(git tag --list 'v*-dev.*'); do
git push origin ":refs/tags/${tag}" || true
done
- name: Create dev draft prerelease
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.dev_tag }}
target_commitish: ${{ github.event.workflow_run.head_sha }}
name: Dev Draft ${{ steps.tag.outputs.dev_tag }}
generate_release_notes: true
draft: true
prerelease: true