Create a snapshot NPM release with
/snapitcomment in a PR
This GitHub action allows for automation of Chagesets 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
comment_command: /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
comment_command: /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)[https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry].
build_script (optional)
The build script to run before publishing.
comment_command (optional, default /snapit)
The comment to write to trigger the creation of a snapshot.
branch (optional)
Push the changes to a branch instead of publishing to the NPM registry.
custom_message_prefix (optional)
Custom message to added to the beginning of the release GitHub comment. By default a generic message is shown: "Test the snapshots by updating your package.json with the newly published versions:"
custom_message_suffix (optional)
Custom message to added to the end of the release GitHub comment.
global_install (optional)
If true, the generated GitHub comment will show the command to install your packages globally. Otherwise, the default behaviour is to show a json example to update your local dependencies.
github_comment_included_packages (optional)
In workspaces where many packages are deployed, use this filter if you only want to include some of them in the release GitHub comment. (To specify multiple packages, separate using commas)
To contribute a change, bug fix or feature to snapit:
- Make a new branch
my-branch - Make the changes you need
- Run
pnpm 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.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
