Skip to content

Commit 3ad165d

Browse files
committed
chore(ci): add tag script
Signed-off-by: Matt Roberts <code@rbrts.uk>
1 parent 1a690b9 commit 3ad165d

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

.github/workflows/npm-publish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ jobs:
3232
- run: npm ci
3333
- run: npm run build --if-present
3434

35+
- name: tag
36+
id: tag
37+
run: |
38+
node ./scripts/tag.js ${{ github.event.release.tag_name }}
39+
40+
3541
- name: publish
3642
run: |
37-
npm version --no-git-tag-version --yes --exact ${{ steps.timestamp.outputs.stamp }}
43+
npm version --no-git-tag-version --yes --exact ${{ github.event.release.tag_name }}
3844
npm publish --access public --provenance ${{ steps.tag.outputs.tag }} 2>&1

scripts/tag.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
/*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
'use strict';
17+
18+
const semver = require('semver');
19+
const targetVersion = process.argv[2];
20+
21+
if (!semver.valid(targetVersion)) {
22+
console.error(`Error: the version "${targetVersion}" is invalid!`);
23+
process.exit(1);
24+
}
25+
26+
const prerelease = semver.prerelease(targetVersion);
27+
const tag = prerelease ? 'unstable' : 'latest';
28+
29+
console.log(`::set-output name=tag::--tag=${tag}`);

0 commit comments

Comments
 (0)