Release Snapshots #248
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Release snapshot packages to NPM. | |
name: Release Snapshots | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- develop | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release-snapshots: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 21 | |
- uses: pnpm/action-setup@v3 | |
name: Install pnpm | |
with: | |
version: 9 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm i | |
- name: Build packages | |
run: pnpm run build:packages | |
- name: Add snapshot changeset (ensure at least has a changeset) | |
run: | | |
cat << EOF > ".changeset/snap-release-changeset.md" | |
--- | |
"@rgbpp-sdk/btc": patch | |
--- | |
Add temp changeset for snapshot releases | |
EOF | |
- name: Version packages to "0.0.0-snap-{timestamp}" | |
run: npx changeset version --snapshot snap | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish snapshot versions to npm | |
uses: changesets/action@v1 | |
id: changesets | |
with: | |
publish: npx changeset publish --snapshot --tag snap | |
createGithubReleases: false | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create comment on commit | |
uses: actions/github-script@v7 | |
if: steps.changesets.outputs.published | |
env: | |
PACKAGES: ${{ steps.changesets.outputs.publishedPackages }} | |
with: | |
script: | | |
const packages = JSON.parse(process.env.PACKAGES) | |
const packagesTable = packages.map((p) => `| ${p.name} | \`${p.version}\` |`).join('\n') | |
const body = ['New snapshot version of the rgbpp-sdk packages have been released:', '| Name | Version |', '| --- | --- |', packagesTable].join('\n') | |
github.rest.repos.createCommitComment({ | |
commit_sha: context.sha, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body, | |
}); |