-
-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (49 loc) · 1.43 KB
/
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
50
name: Release
on:
workflow_run:
workflows:
- Tagging
types:
- completed
branches:
- main
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'main') && github.event_name != 'schedule' }}
steps:
- name: Set Tag Value
run: |
export DATE=v$(echo `date +'%Y.%m'`)
echo "DATE=${DATE}" >> $GITHUB_ENV
echo "TAG=$(echo `git tag -l ${DATE}`)" >> $GITHUB_ENV
- name: Create Release
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const { repo: { owner, repo }, sha } = context;
const tag = process.env.DATE;
let release_id = 0;
try {
const release = await github.rest.repos.createRelease({
owner, repo,
tag_name: tag,
title: tag,
name: tag,
draft: false,
make_latest: "true",
target_commitish: sha
});
release_id = release.data.id;
} catch (e) {
let latest;
if (e.status == 422) { // Release alredy exists
latest = await github.rest.repos.getLatestRelease({
owner, repo
});
}
release_id = latest.data.id;
}
return release_id