File tree Expand file tree Collapse file tree 5 files changed +161
-1
lines changed Expand file tree Collapse file tree 5 files changed +161
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Prepare Release
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ tags :
7+ - ' v*'
8+
9+ env :
10+ CI : true
11+
12+ permissions :
13+ contents : read
14+
15+ jobs :
16+ build :
17+ permissions :
18+ contents : write # for softprops/action-gh-release to create GitHub release
19+
20+ runs-on : ubuntu-latest
21+
22+ strategy :
23+ matrix :
24+ node-version : [18]
25+
26+ steps :
27+ - uses : actions/checkout@v3
28+
29+ - run : git fetch --tags -f
30+
31+ - name : Resolve version
32+ id : vars
33+ run : |
34+ echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
35+
36+ - name : Get release notes
37+ run : |
38+ RELEASE_NOTES=$(npm run release-notes --silent)
39+ echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
40+ echo "$RELEASE_NOTES" >> $GITHUB_ENV
41+ echo "EOF" >> $GITHUB_ENV
42+
43+ - name : Use Node.js ${{ matrix.node-version }}
44+ uses : actions/setup-node@v3
45+ with :
46+ node-version : ${{ matrix.node-version }}
47+ registry-url : ' https://registry.npmjs.org'
48+
49+ - name : Release
50+ uses : softprops/action-gh-release@v1
51+ with :
52+ draft : true
53+ tag_name : ${{ env.TAG_NAME }}
54+ body : |
55+ ${{ env.RELEASE_NOTES }}
Original file line number Diff line number Diff line change 1+ name : Release
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ permissions :
8+ contents : read
9+
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+ cancel-in-progress : true
13+
14+ env :
15+ CI : true
16+ CACHE_PREFIX : stable
17+ NODE_VERSION : 16
18+
19+ jobs :
20+ build :
21+ runs-on : ubuntu-latest
22+
23+ steps :
24+ - uses : actions/checkout@v3
25+
26+ - name : Use Node.js ${{ env.NODE_VERSION }}
27+ uses : actions/setup-node@v3
28+ with :
29+ node-version : ${{ env.NODE_VERSION }}
30+ registry-url : " https://registry.npmjs.org"
31+
32+ - name : Use cached node_modules
33+ id : cache
34+ uses : actions/cache@v3
35+ with :
36+ path : node_modules
37+ key : ${{ runner.os }}-${{ env.NODE_VERSION }}-${{ env.CACHE_PREFIX }}-node_modules-${{ hashFiles('**/package-lock.json') }}
38+
39+ - name : Install dependencies
40+ run : npm install
41+
42+ - name : Build Prettier Plugin
43+ run : |
44+ npm run build
45+
46+ - name : Test
47+ run : |
48+ npm run test
49+
50+ - name : Calculate environment variables
51+ run : |
52+ echo "RELEASE_CHANNEL=$(npm run release-channel --silent)" >> $GITHUB_ENV
53+
54+ - name : Publish
55+ run : npm publish --tag ${{ env.RELEASE_CHANNEL }}
56+ env :
57+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 2424 "pretest" : " node scripts/install-fixture-deps.js" ,
2525 "test" : " jest" ,
2626 "prepublishOnly" : " npm run build && npm test && node scripts/copy-licenses.js" ,
27- "format" : " prettier \" src/**/*.js\" \" scripts/**/*.js\" \" tests/test.js\" --write --print-width 100 --single-quote --no-semi --plugin-search-dir ./tests"
27+ "format" : " prettier \" src/**/*.js\" \" scripts/**/*.js\" \" tests/test.js\" --write --print-width 100 --single-quote --no-semi --plugin-search-dir ./tests" ,
28+ "release-channel" : " node ./scripts/release-channel.js" ,
29+ "release-notes" : " node ./scripts/release-notes.js"
2830 },
2931 "devDependencies" : {
3032 "@ianvs/prettier-plugin-sort-imports" : " ^3.7.0" ,
Original file line number Diff line number Diff line change 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 ] ||
12+ process . env . npm_package_version ||
13+ require ( '../package.json' ) . version
14+
15+ let match = / \d + \. \d + \. \d + - ( .* ) \. \d + / g. exec ( version )
16+ if ( match ) {
17+ console . log ( match [ 1 ] )
18+ } else {
19+ console . log ( 'latest' )
20+ }
Original file line number Diff line number Diff line change 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+
4+ let path = require ( 'path' )
5+ let fs = require ( 'fs' )
6+
7+ let version =
8+ process . argv [ 2 ] ||
9+ process . env . npm_package_version ||
10+ require ( '../package.json' ) . version
11+
12+ let changelog = fs . readFileSync (
13+ path . resolve ( __dirname , '..' , 'CHANGELOG.md' ) ,
14+ 'utf8' ,
15+ )
16+ let match = new RegExp (
17+ `## \\[${ version } \\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))` ,
18+ 'g' ,
19+ ) . exec ( changelog )
20+
21+ if ( match ) {
22+ let [ , , notes ] = match
23+ console . log ( notes . trim ( ) )
24+ } else {
25+ console . log ( `Placeholder release notes for version: v${ version } ` )
26+ }
You can’t perform that action at this time.
0 commit comments