Version Packages (#66) #109
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 | |
# Run the workflow when a Pull Request is opened or when changes are pushed to master | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
jobs: | |
test: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
# Run the steps below with the following versions of Node.js | |
node-version: [20.x, 22.x] | |
steps: | |
# Fetch the latest commit | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Setup Node.js using the appropriate version | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# Install package dependencies | |
- name: Install | |
run: npm ci | |
# Run build | |
- name: Build | |
run: yarn build | |
# Run tests | |
- name: Test | |
run: yarn test | |
# - name: Coveralls | |
# uses: coverallsapp/github-action@v2 | |
# with: | |
# github-token: ${{ secrets.GITHUB_TOKEN }} | |
release: | |
strategy: | |
matrix: | |
# Run the steps below with the following versions of Node.js | |
node-version: [22.x] | |
# Only release on push to main | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: macos-latest | |
# Waits for test jobs for each Node.js version to complete | |
needs: [test] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Setup Node.js using the appropriate version | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
# Install package dependencies | |
- name: Install | |
run: npm ci | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
# This expects you to have a script called release which does a build for your packages and calls changeset publish | |
publish: yarn release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |