-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.88 KB
/
tagcreated.yml
File metadata and controls
52 lines (44 loc) · 1.88 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
name: Tag Created
on:
- create
- workflow_dispatch
jobs:
abracadabra:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
script: |
// Matches tags that end with SemVer, e.g. v1.0.1-alpha+20201101.build3
const semver_tag_without_prefix_regex = /^refs\/tags\/(v?((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?))$/;
tag_ref = context.ref;
const match = tag_ref.match(semver_tag_without_prefix_regex);
if (match === null) { core.setFailed(`not a SemVer tag`); return; }
const is_prerelease = match[6] === undefined ? false : true;
console.log("repo owner:", context.repo.owner);
console.log("repo name:", context.repo.repo);
console.log("tag:", match[1]);
console.log("is prerelease:", is_prerelease);
github.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: match[1],
}).then(res => {
core.setFailed("Releases with this tag already exist.");
return;
}).catch(err => {
if (err.status == 404) {
core.debug("Did not find releases with this tag.");
} else {
core.setFailed(`weird response status code: ${err.status}`);
return;
}
});
//console.log("ex rel:", existing_release);
/*github.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: match[1],
draft: true,
prerelease: is_prerelease,
});*/