Skip to content

Use cache instead of artifact in github action #7

Use cache instead of artifact in github action

Use cache instead of artifact in github action #7

Workflow file for this run

name: CI/CD
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
GIT_AUTHOR_EMAIL: [email protected]
GIT_AUTHOR_NAME: smartsquare-bot
GIT_COMMITTER_EMAIL: [email protected]
GIT_COMMITTER_NAME: smartsquare-bot
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "21.7.3"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# Not needed for now
# - name: Generate examples index
# run: npm run generate-examples-index
# Uncomment when code base is ready
# - name: Lint
# run: npm run lint
- name: Test
run: npm run test-cov
- name: Cache build outputs and dependencies
uses: actions/cache/save@v4
with:
path: |
declarations/
dist/
esnext/
peer/
standalone/
styles/
types/
examples/
coverage/
docs/
node_modules/
LICENSE*
*.html
*.md
key: ${{ runner.os }}-build-deps-${{ github.sha }}
release:
needs: build-and-test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "21.7.3"
registry-url: "https://registry.npmjs.org"
- name: Restore cached build outputs and dependencies
uses: actions/cache/restore@v4
with:
path: |
declarations/
dist/
esnext/
peer/
standalone/
styles/
types/
examples/
coverage/
docs/
node_modules/
LICENSE*
*.html
*.md
key: ${{ runner.os }}-build-deps-${{ github.sha }}
fail-on-cache-miss: true
- name: Release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org"
run: npx semantic-release
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance