Merge pull request #22 from edspencer/changeset-release/main #50
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
name: Test and Release | |
on: | |
push: | |
branches: | |
- '**' # Runs on all branches | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9.7.0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run tests | |
run: npx jest | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/main' # Only run this job on the main branch | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9.7.0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "pnpm" | |
registry-url: "https://registry.npmjs.org" | |
- name: Install dependencies | |
run: pnpm install | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
publish: npm run ci:publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |