Create a snapshot NPM release with
/snapitcomment in a PR
This GitHub action allows for automation of Changesets Snapshot Release with the comment /snapit in a pull request. Snapshot releases are a way to release your changes for testing without updating the versions.
Create a .github/workflows/snapit.yml file with the following contents.
Deploy to NPM
name: Snapit
on:
issue_comment:
types:
- created
jobs:
snapit:
name: Snapit
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v4
- name: Create snapshot version
uses: Shopify/snapit@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
build_script: pnpm build # Optional
trigger_comment: /snapit # Default value not requiredDeploy to branch
This is useful when orchestrating releases outside of GitHub actions or with other package registries.
name: Snapit
on:
issue_comment:
types:
- created
jobs:
snapit:
name: Snapit
runs-on: ubuntu-latest
steps:
- name: Checkout default branch
uses: actions/checkout@v4
- name: Create snapshot version
uses: Shopify/snapit@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: snapshot-release
trigger_comment: /snapit # Default value not requiredGITHUB_TOKEN
The GITHUB_TOKEN is needed for changesets to look up the current changeset when creating a snapshot. You can use the automatically created ${{ secrets.GITHUB_TOKEN }} to authenticate in the workflow job.
NPM_TOKEN
A NPM_TOKEN needs to be created and added to the repository to publish packages from GitHub actions to the npm registry.
| Inputs (All Optional) | Description |
|---|---|
trigger_comment |
Default: /snapit. Comma seperated list of comments to write to trigger the creation of a snapshot. |
comment_prefix |
Custom message to add to the beginning of the release GitHub comment. Default: "Test the snapshots by updating your package.json with the newly published versions:" |
comment_suffix |
Custom message to add to the end of the release GitHub comment. |
comment_packages |
Filter to include specific packages in the release GitHub comment. Separate multiple packages with commas. |
comment_is_global |
If true, the generated GitHub comment will show the command to install your packages globally. Otherwise, shows a JSON example to update local dependencies. |
cwd |
If specified, the action will run all commands for snapit in the specified directory. |
branch |
Push the changes to a branch instead of publishing to the NPM registry. |
post_install_script |
If specified, will run a script after dependencies are installed. |
build_script |
The build script to run before publishing. |
release_branch |
Default: changeset-release/main. If specified, will use this branch name in place of the default |
To contribute a change, bug fix or feature to snapit:
- Make a new branch
my-branch - Make the changes you need
- Run
npm run build - Push your changes to the branch
- In your repositories
mainbranch point the.github/snapit.ymlfile to theshopify/snapitbranchuses: Shopify/snapit@my-branch - Create a pull request with changeset and write
/snapitas a comment in the pull request
v0.0.15
- Add
release_branchto configure the default release branch. Default ischangeset-release/main.
v0.0.14
- Improved error logging
build_scriptis now optional- Adds optional
working_directoryto run snap it commands from - Adds optional
post_installscript
v0.0.13
- Add
global_installto show global npm installation instructions on the generated GitHub comment. - Add
github_comment_included_packagesto allow including just some packages on the generated GitHub comment. - Rename
custom_messagetocustom_message_prefix - Add
custom_message_suffix
v0.0.12
- Fix typo in snapshot comment message
v0.0.11
- Capture snapshot versions before
build_script
v0.0.10
- Disallow private packages from being published
- Check for snapshots before getting the timestamp
- Skip packages that do not have a
nameorversion
v0.0.9
- Add
branchto publish to other package services - Add
custom_messageto add a markdown string to the generated GitHub comment - Add missing comma to GitHub comment seperating versions
v0.0.8
- Add space between package name and version in GitHub comment
v0.0.7
- Simplify GitHub comment
v0.0.6
- Add support for pnpm
v0.0.5
- Reorder
build_scriptto run afterchangeset version
v0.0.4
- Improve error handling
- Update action to use TypeScript
v0.0.3
- Fix issue with Version Packages PRs not resetting changesets
- Allow
build_scriptto have&&when multiple scripts are needed - Make
build_scriptoptional for projects that do not need a build
v0.0.2
- Install comment recommends
yarn addif the project has ayarn.lock - Fix issue with PR changes not being included in snapshot version
- Optionally change the comment to trigger the snapshot with the
comment_commandinput
v0.0.1
- Initial version used by
@shopify/polaris
