Skip to content

Commit 9fada99

Browse files
committed
improve consistency for relase related scripts
1 parent addaf45 commit 9fada99

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ jobs:
4747

4848
- name: Calculate environment variables
4949
run: |
50-
echo "TAG_NAME=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV
50+
echo "RELEASE_CHANNEL=$(npm run release-channel --silent)" >> $GITHUB_ENV
5151
5252
- name: Publish
53-
run: npm publish --tag ${{ env.TAG_NAME }}
53+
run: npm publish --tag ${{ env.RELEASE_CHANNEL }}
5454
env:
5555
CI: true
5656
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"dev": "npm run swcify -- --watch",
1616
"postbuild": "tsc --emitDeclarationOnly",
1717
"prepublishOnly": "npm run build",
18+
"release-channel": "node ./scripts/release-channel.js",
1819
"release-notes": "node ./scripts/release-notes.js"
1920
},
2021
"prettier": {

scripts/release-channel.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Given a version, figure out what the release channel is so that we can publish to the correct
2+
// channel on npm.
3+
//
4+
// E.g.:
5+
//
6+
// 1.2.3 -> latest (default)
7+
// 0.0.0-insiders.ffaa88 -> insiders
8+
// 4.1.0-alpha.4 -> alpha
9+
10+
let version =
11+
process.argv[2] || process.env.npm_package_version || require('../package.json').version
12+
13+
let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version)
14+
if (match) {
15+
console.log(match[1])
16+
} else {
17+
console.log('latest')
18+
}

scripts/release-notes.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
// Given a version, figure out what the release notes are so that we can use this to pre-fill the
2+
// relase notes on a GitHub release for the current version.
3+
14
let path = require('path')
25
let fs = require('fs')
36

4-
let version = process.argv[2] || require('../package.json').version
7+
let version =
8+
process.argv[2] || process.env.npm_package_version || require('../package.json').version
9+
510
let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8')
611
let match = new RegExp(
712
`## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`,

0 commit comments

Comments
 (0)