File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed
Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ name : " Determine version"
2+ description : " Determines npm package version based on PR number and commit SHA"
3+ outputs :
4+ version :
5+ description : " npm package version"
6+ runs :
7+ using : " node20"
8+ main : " index.js"
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const path = require ( 'path' )
3+ const core = require ( '@actions/core' )
4+
5+ try {
6+ const packageJSONPath = path . join (
7+ process . cwd ( ) ,
8+ `packages/${ process . env . PACKAGE_PATH || 'react' } /package.json` ,
9+ )
10+ const packageJSON = JSON . parse ( fs . readFileSync ( packageJSONPath , 'utf8' ) )
11+
12+ const sha8 = process . env . GITHUB_SHA . substring ( 0 , 8 )
13+ const prefix = '0.0.0-'
14+ const packageVersion = `${ prefix } manual.${ sha8 } `
15+ packageJSON . version = packageVersion
16+ core . setOutput ( 'version' , packageVersion )
17+ fs . writeFileSync ( packageJSONPath , JSON . stringify ( packageJSON ) )
18+ } catch ( error ) {
19+ core . setFailed ( error . message )
20+ }
Original file line number Diff line number Diff line change 1+ name : Manual Release
2+
3+ on :
4+ push :
5+ branches :
6+ - mainline
7+ pull_request :
8+ # TODO: Support latest releases
9+ workflow_dispatch :
10+ inputs :
11+ name :
12+ type : choice
13+ description : Package name (npm)
14+ options :
15+ - " @abstract-money/core"
16+ - " @abstract-money/cli"
17+ - " @abstract-money/react"
18+ # TODO: Infer from package name
19+ path :
20+ type : choice
21+ description : Directory name (packages/*)
22+ options :
23+ - " core"
24+ - " cli"
25+ - " react"
26+ env :
27+ FORCE_COLOR : true
28+
29+ jobs :
30+ release-manual :
31+ name : Publish manually
32+ runs-on : ubuntu-latest
33+ if : ${{ github.event_name == 'workflow_dispatch' }}
34+ steps :
35+ - uses : actions/checkout@v4
36+ with :
37+ # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
38+ fetch-depth : 0
39+ submodules : true
40+
41+ - name : Install dependencies
42+ uses : ./.github/actions/install-dependencies
43+
44+ - name : Determine version
45+ uses : ./.github/actions/version-pr
46+ id : determine-version
47+ env :
48+ PACKAGE_PATH : ${{ github.event.inputs.path }}
49+ - name : Publish to npm
50+ run : |
51+ pnpm build
52+ cd packages/$PACKAGE_PATH
53+ echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
54+ pnpm publish --no-git-checks --access public --tag experimental
55+ echo "🎉 Experimental release published 📦️ on npm: https://npmjs.com/package/${{ github.event.inputs.name }}/v/${{ env.VERSION }}"
56+ echo "Install via: pnpm add ${{ github.event.inputs.name }}@${{ env.VERSION }}"
57+ env :
58+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
59+ PACKAGE_PATH : ${{ github.event.inputs.path }}
60+ VERSION : ${{ steps.determine-version.outputs.version }}
You can’t perform that action at this time.
0 commit comments