Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

chore: update dependencies (#44) #139

chore: update dependencies (#44)

chore: update dependencies (#44) #139

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# Always use Node 20
# Add Node 18 to the matrix if we’re in the release PR
define-matrix:
runs-on: ubuntu-latest
outputs:
node-versions: ${{ steps.node-versions.outputs.node-versions }}
steps:
- name: Node version matrix
id: node-versions
run: |
if [ "${{ github.head_ref }}" == "changeset-release/main" ]; then
echo 'node-versions=[18, 20]' >> "$GITHUB_OUTPUT"
else
echo 'node-versions=[20]' >> "$GITHUB_OUTPUT"
fi
- name: Print Node version matrix
run: echo "node-versions=${{ steps.node-versions.outputs.node-versions }}"
- name: Check Node version matrix
run: |
if [ "${{ steps.node-versions.outputs.node-versions }}" != "[18, 20]" ] && [ "${{ steps.node-versions.outputs.node-versions }}" != "[20]" ]; then
echo "Node version matrix is not [18, 20] or [20]"
exit 1
fi
build:
runs-on: ubuntu-20.04
needs: define-matrix
strategy:
matrix:
node-version: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Turborepo cache
uses: actions/cache@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
- name: Build
run: pnpm turbo build
- name: Update Turborepo cache
uses: actions/cache/save@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
format:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dev dependencies
run: pnpm install --dev
- name: Check code style
run: pnpm format:check
types:
runs-on: ubuntu-20.04
needs: [define-matrix, build]
strategy:
matrix:
node-version: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Turborepo cache
uses: actions/cache/restore@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
- name: Build
run: pnpm turbo build
- if: matrix.node-version == 20 || github.head_ref == 'changeset-release/main'
name: Check types
run: pnpm turbo types:check
test:
runs-on: ubuntu-20.04
needs: [define-matrix, build]
strategy:
matrix:
node-version: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Turborepo cache
uses: actions/cache/restore@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
- name: Build
run: pnpm build
- name: Run tests
run: pnpm test
release:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-20.04
permissions:
contents: write
id-token: write
needs: [build, test]
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Turborepo cache
uses: actions/cache/restore@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
- name: Build
run: pnpm turbo build
- name: Git Status
run: git status
- name: Stash changes
run: git stash
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# The pull request title.
title: 'chore: release'
# The command to update version, edit CHANGELOG, read and delete changesets.
version: 'pnpm changeset version'
# The commit message to use.
commit: 'chore: version packages'
# The command to use to build and publish packages
publish: 'pnpm -r publish --access public'
env:
# https://github.com/settings/tokens/new
# Expiration: No expiration
# Select: repo.*
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
# https://www.npmjs.com/settings/YOUR_ACCOUNT_HANDLE/tokens/granular-access-tokens/new
# Custom Expiration: 01-01-2100
# Permissions: Read and Write
# Select packages: @scalar
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}