Skip to content

Commit 577dce4

Browse files
committed
Merge pull request #65 from andrewbranch/infra/publish-alpha
Add job for publishing alpha to npm
1 parent fd0b3bd commit 577dce4

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.github/workflows/getVersion.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @param {string | number} value
3+
* @param {number} length
4+
*/
5+
function padInt(value, length) {
6+
value = value.toString();
7+
while (value.length < length) {
8+
value = "0" + value;
9+
}
10+
return value;
11+
}
12+
13+
const version = process.argv[2];
14+
if (!version || !/\d+\.\d+\.\d+/.test(version)) {
15+
throw new Error(`Must provide base version, e.g. 'node getVersion.js 2.0.0'`);
16+
}
17+
const date = new Date();
18+
const timestamp = [
19+
date.getUTCFullYear(),
20+
padInt(date.getUTCMonth() + 1, 2),
21+
padInt(date.getUTCDate(), 2),
22+
].join('');
23+
24+
console.log(`${version}-alpha.${timestamp}`);

.github/workflows/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,23 @@ jobs:
5151
run: npm publish
5252
env:
5353
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
publish_alpha:
55+
if: github.event_name == 'push' && github.ref == 'v2'
56+
needs: build_test
57+
name: publish alpha version to npm
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v1
61+
- uses: actions/setup-node@v1
62+
with:
63+
node-version: '12'
64+
registry-url: 'https://registry.npmjs.org'
65+
- name: install
66+
run: npm ci
67+
- name: build
68+
run: npm run build
69+
- name: publish alpha
70+
run: |
71+
version=`node .github/workflows/getVersion.js 2.0.0`
72+
npm --no-git-tag-version version $version
73+
npm publish --tag alpha

0 commit comments

Comments
 (0)