Skip to content

Commit d2c8d6c

Browse files
committed
Chore: Additional documentation for publishing on Actions
1 parent 8c527c7 commit d2c8d6c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,65 @@ If you're going to run `xs test` on GitHub Actions, please keep in mind that it
161161
- name: Test
162162
run: xvfb-run --auto-servernum npm test
163163
```
164+
165+
### Publishing on GitHub Actions
166+
167+
Publishing on GitHub Actions requires a little customization. Typically, running `xs release` locally will also publish, however, if you want to defer publishing on GitHub Actions, you can modify the default `xs release` in your **package.json** like this:
168+
169+
```json
170+
{
171+
"scripts": {
172+
"build": "xs build",
173+
"release": "xs bump,test,deploy,git-push",
174+
"publish-ci": "xs publish",
175+
}
176+
}
177+
```
178+
179+
Here's a snippet of the a GitHub Actions workflow to trigger a publish when a release is published. For more information on creating publishing workflow check out this [documentation](https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages).
180+
181+
```yml
182+
name: Publish Package
183+
on:
184+
release:
185+
types: [published]
186+
jobs:
187+
publish:
188+
- uses: actions/checkout@v4
189+
- uses: actions/setup-node@v4
190+
with:
191+
node-version: '20.x'
192+
registry-url: 'https://registry.npmjs.org'
193+
- run: npm ci
194+
- run: npm run build
195+
- run: npm run publish-ci
196+
env:
197+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
198+
```
199+
200+
Finally, if you need to publishing to a different [dist-tag](https://docs.npmjs.com/cli/v10/commands/npm-dist-tag) when publishing, you can use the `XS_PUBLISH_TAG` environment variable. In this example, prereleases will be published to a `beta` dist-tag.
201+
202+
```yml
203+
name: Publish Package
204+
on:
205+
release:
206+
types: [published]
207+
jobs:
208+
publish:
209+
- uses: actions/checkout@v4
210+
- uses: actions/setup-node@v4
211+
with:
212+
node-version: '20.x'
213+
registry-url: 'https://registry.npmjs.org'
214+
- run: npm ci
215+
- run: npm run build
216+
- run: npm run publish-ci
217+
if: github.event.release.prerelease
218+
env:
219+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
220+
XS_PUBLISH_TAG: beta
221+
- run: npm run publish-ci
222+
if: github.event.release.prerelease == false
223+
env:
224+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
225+
```

0 commit comments

Comments
 (0)