44 branches :
55 - master
66 - develop
7+ workflow_dispatch :
8+ inputs :
9+ snapshot_tag :
10+ description : ' changesets snapshot tag (beta/canary)'
11+ required : false
12+ default : ' beta'
13+ type : string
14+ npm_tag :
15+ description : ' npm tag for publishing snapshot'
16+ required : false
17+ default : ' beta'
18+ type : string
19+ npm_access :
20+ description : ' access level for publishing snapshot to npm'
21+ required : false
22+ default : ' public'
23+ type : choice
24+ options :
25+ - public
26+ - restricted
727env :
828 NX_CLOUD_ENCRYPTION_KEY : ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
929 NX_CLOUD_ACCESS_TOKEN : ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
30+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
31+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
32+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
33+ SLACK_WEBHOOK_URL_BETA : ${{ secrets.SLACK_WEBHOOK_URL_BETA }}
1034 NX_CLOUD_DISTRIBUTED_EXECUTION : true
11- PNPM_CACHE_FOLDER : .pnpm-store
12- NPM_ACCESS_TOKEN : ${{ secrets.NPM_ACCESS_TOKEN }}
1335 HUSKY : 0
36+ CI : true
1437
1538jobs :
39+ # On push to develop/master, create or update release PR or publish to npm
1640 publish-or-pr :
41+ if : github.event_name == 'push'
42+ name : Create/update release PR or publish to npm
1743 permissions :
1844 contents : write # to create release (changesets/action)
1945 issues : write # to post issue comments (changesets/action)
2046 pull-requests : write # to create pull request (changesets/action)
21- id-token : write # give id token write for provenance
47+ id-token : write # OIDC for provenance if npm publish happens here
2248 runs-on : ubuntu-latest
2349 steps :
24- - uses : actions/checkout@v4
25- with :
26- fetch-depth : 0
27- - uses : pnpm/action-setup@v4
28- with :
29- run_install : false
30- - uses : actions/setup-node@v4
31- id : cache
32- with :
33- node-version : ' 20.10.0'
34- cache : ' pnpm'
35-
36- - run : pnpm install --frozen-lockfile
37-
38- # This line enables distribution
39- # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
40- - run : pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" --verbose
41-
42- - run : pnpm exec playwright install
50+ - name : Branch name
51+ run : |
52+ echo "Checking out branch: ${{ github.ref_name }}"
4353
44- - uses : nrwl/nx-set-shas@v4
54+ - name : Checkout repository
55+ uses : actions/checkout@v4
4556 with :
46- main-branch-name : master
47-
48- - name : setup pnpm config
49- run : pnpm config set store-dir $PNPM_CACHE_FOLDER
50-
51- - run : pnpm exec nx affected -t build lint test e2e-ci --verbose
57+ fetch-depth : 0
5258
53- - uses : actions/upload-artifact@v4
54- if : ${{ !cancelled() }}
59+ - name : Setup publish
60+ uses : ./.github/actions/setup-publish
5561 with :
56- name : playwright-report
57- path : |
58- ./dist/.playwright/**
59- ./dist/**
60- retention-days : 30
61-
62- # make sure we have a build.
63- - run : pnpm exec nx run-many -t build
64- env :
65- NX_CLOUD_DISTRIBUTED_EXECUTION : false
62+ CODECOV_TOKEN : ${{ env.CODECOV_TOKEN }}
6663
67- - run : git status
68- - name : publish
64+ # This action creates a release pull request with all of
65+ # the package versions and changelogs updated. When there
66+ # are new changesets on your configured baseBranch, the PR will
67+ # be updated. When you're ready, you can merge the release PR
68+ # and the action will publish to npm for you.
69+ # https://github.com/changesets/action
70+ - name : Create/update release PR or publish to npm
6971 uses : changesets/action@v1
7072 id : changesets
7173 with :
72- publish : pnpm ci:release
73- version : pnpm ci:version
74- title : Release PR
75- branch : master
76- commit : ' chore: version-packages'
74+ publish : pnpm ci:release # command to tag and publish packages
75+ version : pnpm ci:version # command to update version, edit changelog, read and delete changesets
76+ branch : master # the branch to base the release PR against
77+ title : Release PR # title for the release PR
78+ commit : ' chore: version-packages' # the commit message to use
7779 setupGitUser : true
7880 env :
79- # See https://github.com/changesets/action/issues/147
80- HOME : ${{ github.workspace }}
81- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82- NPM_CONFIG_PROVENANCE : ' true '
83- NPM_TOKEN : ${{ secrets.NPM_ACCESS_TOKEN }}
84-
85- - name : rebase develop with main on publish
86- if : ${{ steps.changesets.outputs.published == 'true' }}
81+ GITHUB_TOKEN : ${{ env.GITHUB_TOKEN }}
82+
83+ - name : Publish previews to Stackblitz on PR
84+ if : steps.changesets.outputs.published == 'false '
85+ run : pnpm pkg-pr-new publish './packages/*' --packageManager=pnpm --comment=off
86+
87+ - name : Rebase develop with master on publish
88+ if : steps.changesets.outputs.published == 'true'
8789 run : |
8890 git restore .
8991 git checkout master
@@ -95,10 +97,73 @@ jobs:
9597 git rebase master
9698 git push -f
9799 env :
98- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
99- NPM_CONFIG_PROVENANCE : true
100+ GITHUB_TOKEN : ${{ env.GITHUB_TOKEN }}
101+
102+ - name : Format published packages for Slack
103+ if : steps.changesets.outputs.published == 'true'
104+ id : format-packages
105+ run : |
106+ PACKAGES=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | ":package: *\(.name)* `\(.version)`"')
107+ echo "formatted<<EOF" >> $GITHUB_OUTPUT
108+ echo "$PACKAGES" >> $GITHUB_OUTPUT
109+ echo "EOF" >> $GITHUB_OUTPUT
100110
101- - uses : codecov/codecov-action@v5
111+ - name : Send GitHub Action data to a Slack workflow
112+ if : steps.changesets.outputs.published == 'true'
113+ uses : slackapi/slack-github-action@v2.1.1
114+ with :
115+ payload-delimiter : ' _'
116+ webhook : ${{ env.SLACK_WEBHOOK_URL }}
117+ webhook-type : webhook-trigger
118+ payload : |
119+ publishedPackages: ${{ steps.format-packages.outputs.formatted }}
120+
121+ - name : Run code coverage
122+ uses : codecov/codecov-action@v5
102123 with :
103124 files : ./packages/**/coverage/*.xml
104- token : ${{ secrets.CODECOV_TOKEN }}
125+ token : ${{ env.CODECOV_TOKEN }}
126+
127+ snapshot :
128+ # On manual trigger of GH action, publish a snapshot release to npm
129+ if : github.event_name == 'workflow_dispatch'
130+ name : Publish snapshot/beta release to npm
131+ permissions :
132+ contents : read
133+ id-token : write # OIDC for provenance when npm publish happens
134+ runs-on : ubuntu-latest
135+ steps :
136+ - name : Branch name
137+ run : |
138+ echo "Checking out branch: ${{ github.ref_name }}"
139+
140+ # Checkout the branch selected when triggering the workflow
141+ - name : Checkout repository
142+ uses : actions/checkout@v4
143+ with :
144+ fetch-depth : 0
145+
146+ - name : Setup publish
147+ uses : ./.github/actions/setup-publish
148+ with :
149+ CODECOV_TOKEN : ${{ env.CODECOV_TOKEN }}
150+
151+ - name : Version packages for snapshot
152+ run : pnpm changeset version --snapshot ${{ inputs.snapshot_tag }}
153+ env :
154+ GITHUB_TOKEN : ${{ env.GITHUB_TOKEN }}
155+
156+ - name : Publish packages snapshot with npm_tag
157+ id : npmpublish
158+ run : pnpm publish -r --tag ${{ inputs.npm_tag }} --no-git-checks --access ${{ inputs.npm_access }}
159+
160+ - name : Send GitHub Action data to a Slack workflow
161+ if : steps.npmpublish.outcome == 'success'
162+ uses : slackapi/slack-github-action@v2.1.1
163+ with :
164+ payload-delimiter : ' _'
165+ webhook : ${{ env.SLACK_WEBHOOK_URL_BETA }}
166+ webhook-type : webhook-trigger
167+ payload : |
168+ npmTag: "${{ inputs.npm_tag }}"
169+ publishedPackages: ""
0 commit comments