-
Notifications
You must be signed in to change notification settings - Fork 12
47 lines (40 loc) · 1.34 KB
/
create_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
name: Create Github Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Permission can be added at job level or workflow level
permissions:
contents: write # This is required for actions/checkout and create release
jobs:
release:
name: Github Release
runs-on: ubuntu-latest
steps:
- name: Create Github Release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
if (!${{ toJson(github.ref_name) }}) {
core.setFailed("RELEASE_TAG is not defined.")
return;
}
try {
const response = await github.rest.repos.createRelease({
name: ${{ toJson(github.ref_name) }},
tag_name: ${{ toJson(github.ref_name) }},
draft: false,
generate_release_notes: true,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}