Skip to content

Commit 6dd1f89

Browse files
committed
chore: fix publish workflow for real
1 parent 9d62671 commit 6dd1f89

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

.github/actions/setup-publish/action.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Setup publish
22
description: Setup steps for publishing packages
33

4+
inputs:
5+
CODECOV_TOKEN:
6+
description: 'Codecov token for uploading coverage reports'
7+
required: true
8+
49
runs:
510
using: 'composite'
611
steps:
@@ -11,26 +16,28 @@ runs:
1116

1217
- name: Install Node.js
1318
uses: actions/setup-node@v4
14-
id: cache
1519
with:
16-
node-version: '.node-version'
20+
node-version-file: '.node-version'
1721
cache: 'pnpm' # package manager for caching
1822
registry-url: 'https://registry.npmjs.org'
1923

2024
# Update npm to latest for provenance
2125
- name: Update npm
2226
run: npm install -g npm@latest
27+
shell: bash
2328

2429
- name: Install dependencies from lockfile
2530
run: pnpm install --frozen-lockfile
31+
shell: bash
2632

2733
# Allocate nx tasks across multiple machines/agents in the cloud
2834
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
2935
# https://nx.dev/docs/features/ci-features/distribute-task-execution
3036
- name: Enable distribution of nx tasks to cloud agents
3137
run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
38+
shell: bash
3239
env:
33-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
40+
CODECOV_TOKEN: ${{ inputs.CODECOV_TOKEN }}
3441

3542
# https://github.com/microsoft/playwright/issues/7249#issuecomment-1256878540
3643
- name: Cache Playwright browsers
@@ -43,6 +50,7 @@ runs:
4350
4451
- name: Install Playwright browsers
4552
run: pnpm exec playwright install
53+
shell: bash
4654

4755
- name: Derive SHAs for `nx affected`
4856
uses: nrwl/nx-set-shas@v4
@@ -51,6 +59,7 @@ runs:
5159

5260
- name: Run build, lint, test, and e2e for projects changed
5361
run: pnpm exec nx affected -t build lint test e2e-ci --agents
62+
shell: bash
5463

5564
- name: Save Playwright test results
5665
uses: actions/upload-artifact@v4
@@ -64,3 +73,4 @@ runs:
6473

6574
- name: Ensure builds for all packages before publishing
6675
run: pnpm exec nx run-many -t build --no-agents # --no-agents to run in CI without distributing to agents
76+
shell: bash

.github/workflows/publish.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ on:
2727
env:
2828
NX_CLOUD_ENCRYPTION_KEY: ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
2929
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 }}
3033
HUSKY: 0
3134
CI: true
3235

@@ -42,13 +45,19 @@ jobs:
4245
id-token: write # OIDC for provenance if npm publish happens here
4346
runs-on: ubuntu-latest
4447
steps:
48+
- name: Branch name
49+
run: |
50+
echo "Checking out branch: ${{ github.ref_name }}"
51+
4552
- name: Checkout repository
4653
uses: actions/checkout@v4
4754
with:
4855
fetch-depth: 0
4956

5057
- name: Setup publish
5158
uses: ./.github/actions/setup-publish
59+
with:
60+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
5261

5362
# This action creates a release pull request with all of
5463
# the package versions and changelogs updated. When there
@@ -67,9 +76,8 @@ jobs:
6776
setupGitUser: true
6877
env:
6978
HOME: ${{ github.workspace }} # See https://github.com/changesets/action/issues/147
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
7180
NPM_CONFIG_PROVENANCE: 'true'
72-
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
7381

7482
- name: Publish previews to Stackblitz on PR
7583
if: steps.changesets.outputs.published == 'false'
@@ -88,14 +96,14 @@ jobs:
8896
git rebase master
8997
git push -f
9098
env:
91-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
99+
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
92100

93101
- name: Send GitHub Action data to a Slack workflow
94102
if: steps.changesets.outputs.published == 'true'
95103
uses: slackapi/slack-github-action@v2.1.1
96104
with:
97105
payload-delimiter: '_'
98-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
106+
webhook: ${{ env.SLACK_WEBHOOK_URL }}
99107
webhook-type: webhook-trigger
100108
payload: |
101109
text: ${{ steps.changesets.outputs.publishedPackages }}
@@ -104,7 +112,7 @@ jobs:
104112
uses: codecov/codecov-action@v5
105113
with:
106114
files: ./packages/**/coverage/*.xml
107-
token: ${{ secrets.CODECOV_TOKEN }}
115+
token: ${{ env.CODECOV_TOKEN }}
108116

109117
snapshot:
110118
# On manual trigger of GH action, publish a snapshot release to npm
@@ -115,6 +123,10 @@ jobs:
115123
id-token: write # OIDC for provenance when npm publish happens
116124
runs-on: ubuntu-latest
117125
steps:
126+
- name: Branch name
127+
run: |
128+
echo "Checking out branch: ${{ github.ref_name }}"
129+
118130
# Checkout the branch selected when triggering the workflow
119131
- name: Checkout repository
120132
uses: actions/checkout@v4
@@ -123,21 +135,23 @@ jobs:
123135

124136
- name: Setup publish
125137
uses: ./.github/actions/setup-publish
138+
with:
139+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
126140

127141
- name: Version packages for snapshot
128142
run: pnpm changeset version --snapshot ${{ inputs.snapshot_tag }}
129143
env:
130-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
144+
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
131145

132-
- name: Publish packages snapshot with npm_tag
133-
run: pnpm publish -r --tag ${{ inputs.npm_tag }} --no-git-checks --access ${{ inputs.npm_access }}
146+
# - name: Publish packages snapshot with npm_tag
147+
# run: pnpm publish -r --tag ${{ inputs.npm_tag }} --no-git-checks --access ${{ inputs.npm_access }}
134148

135149
- name: Send GitHub Action data to a Slack workflow
136150
if: steps.changesets.outputs.published == 'true'
137151
uses: slackapi/slack-github-action@v2.1.1
138152
with:
139153
payload-delimiter: '_'
140-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
154+
webhook: ${{ env.SLACK_WEBHOOK_URL }}
141155
webhook-type: webhook-trigger
142156
payload: |
143157
text: ${{ steps.changesets.outputs.publishedPackages }}

0 commit comments

Comments
 (0)