Skip to content

Commit 6cb0577

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

2 files changed

Lines changed: 41 additions & 13 deletions

File tree

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

Lines changed: 14 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,16 +59,19 @@ 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
5766
if: ${{ !cancelled() }}
5867
with:
5968
name: playwright-report
6069
path: |
70+
./**/.playwright/**
6171
./dist/.playwright/**
6272
./dist/**
6373
retention-days: 30
6474

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

.github/workflows/publish.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ 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 }}
33+
SLACK_WEBHOOK_URL_BETA: ${{ secrets.SLACK_WEBHOOK_URL_BETA }}
3034
HUSKY: 0
3135
CI: true
3236

@@ -42,13 +46,19 @@ jobs:
4246
id-token: write # OIDC for provenance if npm publish happens here
4347
runs-on: ubuntu-latest
4448
steps:
49+
- name: Branch name
50+
run: |
51+
echo "Checking out branch: ${{ github.ref_name }}"
52+
4553
- name: Checkout repository
4654
uses: actions/checkout@v4
4755
with:
4856
fetch-depth: 0
4957

5058
- name: Setup publish
5159
uses: ./.github/actions/setup-publish
60+
with:
61+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
5262

5363
# This action creates a release pull request with all of
5464
# the package versions and changelogs updated. When there
@@ -67,9 +77,8 @@ jobs:
6777
setupGitUser: true
6878
env:
6979
HOME: ${{ github.workspace }} # See https://github.com/changesets/action/issues/147
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
7181
NPM_CONFIG_PROVENANCE: 'true'
72-
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
7382

7483
- name: Publish previews to Stackblitz on PR
7584
if: steps.changesets.outputs.published == 'false'
@@ -88,23 +97,23 @@ jobs:
8897
git rebase master
8998
git push -f
9099
env:
91-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
100+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
92101

93102
- name: Send GitHub Action data to a Slack workflow
94103
if: steps.changesets.outputs.published == 'true'
95104
uses: slackapi/slack-github-action@v2.1.1
96105
with:
97106
payload-delimiter: '_'
98-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
107+
webhook: ${{ env.SLACK_WEBHOOK_URL }}
99108
webhook-type: webhook-trigger
100109
payload: |
101-
text: ${{ steps.changesets.outputs.publishedPackages }}
110+
publishedPackages: steps.changesets.outputs.publishedPackages
102111
103112
- name: Run code coverage
104113
uses: codecov/codecov-action@v5
105114
with:
106115
files: ./packages/**/coverage/*.xml
107-
token: ${{ secrets.CODECOV_TOKEN }}
116+
token: ${{ env.CODECOV_TOKEN }}
108117

109118
snapshot:
110119
# On manual trigger of GH action, publish a snapshot release to npm
@@ -115,6 +124,10 @@ jobs:
115124
id-token: write # OIDC for provenance when npm publish happens
116125
runs-on: ubuntu-latest
117126
steps:
127+
- name: Branch name
128+
run: |
129+
echo "Checking out branch: ${{ github.ref_name }}"
130+
118131
# Checkout the branch selected when triggering the workflow
119132
- name: Checkout repository
120133
uses: actions/checkout@v4
@@ -123,21 +136,25 @@ jobs:
123136

124137
- name: Setup publish
125138
uses: ./.github/actions/setup-publish
139+
with:
140+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
126141

127142
- name: Version packages for snapshot
128143
run: pnpm changeset version --snapshot ${{ inputs.snapshot_tag }}
129144
env:
130-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
145+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
131146

132147
- name: Publish packages snapshot with npm_tag
148+
id: npmpublish
133149
run: pnpm publish -r --tag ${{ inputs.npm_tag }} --no-git-checks --access ${{ inputs.npm_access }}
134150

135151
- name: Send GitHub Action data to a Slack workflow
136-
if: steps.changesets.outputs.published == 'true'
152+
if: steps.npmpublish.outcome == 'success'
137153
uses: slackapi/slack-github-action@v2.1.1
138154
with:
139155
payload-delimiter: '_'
140-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
156+
webhook: ${{ env.SLACK_WEBHOOK_URL_BETA }}
141157
webhook-type: webhook-trigger
142158
payload: |
143-
text: ${{ steps.changesets.outputs.publishedPackages }}
159+
npmTag: "${{ inputs.npm_tag }}"
160+
publishedPackages: ""

0 commit comments

Comments
 (0)