mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Document hasChangesets output (#136)
* Add shouldPublish output * Update README.md Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Remove changeset Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
co-authored by
Mateusz Burzyński
parent
5766bae8d9
commit
b0aaf6aed5
@@ -128,6 +128,51 @@ For example, you can add a step before running the Changesets GitHub Action:
|
|||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Custom Publishing
|
||||||
|
|
||||||
|
If you want to hook into when publishing should occur but have your own publishing functionality you can utilize the `hasChangesets` output.
|
||||||
|
|
||||||
|
Note that you might need to account for things already being published in your script because a commit without any new changesets can always land on your base branch after a successful publish. In such a case you need to figure out on your own how to skip over the actual publishing logic or handle errors gracefully as most package registries won't allow you to publish over already published version.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Node.js 12.x
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 12.x
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: yarn
|
||||||
|
|
||||||
|
- name: Create Release Pull Request or Publish to npm
|
||||||
|
id: changesets
|
||||||
|
uses: changesets/action@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
if: steps.changesets.outputs.hasChangesets == 'false'
|
||||||
|
# You can do something when a publish should happen.
|
||||||
|
run: yarn publish
|
||||||
|
```
|
||||||
|
|
||||||
#### With version script
|
#### With version script
|
||||||
|
|
||||||
If you need to add additional logic to the version command, you can do so by using a version script.
|
If you need to add additional logic to the version command, you can do so by using a version script.
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ outputs:
|
|||||||
publishedPackages:
|
publishedPackages:
|
||||||
description: >
|
description: >
|
||||||
A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]`
|
A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]`
|
||||||
|
hasChangesets:
|
||||||
|
description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality.
|
||||||
branding:
|
branding:
|
||||||
icon: "package"
|
icon: "package"
|
||||||
color: "blue"
|
color: "blue"
|
||||||
|
|||||||
Reference in New Issue
Block a user