Merge pull request #9 from saiichihashimoto/release #16
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
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
name: "Checks" | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: | |
contents: read | |
concurrency: checks-${{ github.ref == 'refs/heads/main' && 'main' || github.event.pull_request.head.sha }} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
issues: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- uses: actions/[email protected] | |
with: | |
node-version-file: "package.json" | |
cache: "npm" | |
- id: node-modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
packages/*/node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- if: steps.node-modules.outputs.cache-hit != 'true' | |
run: npm ci --ignore-scripts | |
- run: npm run build | |
- env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npx semantic-release | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/[email protected] | |
with: | |
node-version-file: "package.json" | |
cache: "npm" | |
- id: node-modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
packages/*/node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- if: steps.node-modules.outputs.cache-hit != 'true' | |
run: npm ci --ignore-scripts | |
- run: npm ls --package-lock-only | |
- uses: actions/cache@v3 | |
with: | |
path: node_modules/.cache/prettier/.prettier-cache | |
key: prettier-${{ github.run_id }} | |
restore-keys: | | |
prettier- | |
- run: npm run lint | |
- run: | | |
if [[ $(git status --porcelain) != "" ]]; then | |
git --no-pager diff --color --text HEAD | |
exit 1 | |
fi | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/[email protected] | |
with: | |
node-version-file: "package.json" | |
cache: "npm" | |
- id: node-modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
packages/*/node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- if: steps.node-modules.outputs.cache-hit != 'true' | |
run: npm ci --ignore-scripts | |
- run: npm ls --package-lock-only | |
- id: cpu-cores | |
uses: SimenB/github-actions-cpu-cores@v2 | |
- run: | | |
JEST_CACHE_DIRECTORY=$(npx jest --color --showConfig | jq --raw-output ".configs[0].cacheDirectory") | |
echo "JEST_CACHE_DIRECTORY=$JEST_CACHE_DIRECTORY" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.JEST_CACHE_DIRECTORY }} | |
key: jest-${{ github.run_id }} | |
restore-keys: | | |
jest- | |
- run: npm test |