chore: Add ability to generate provenance statements #326
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: | |
- main | |
- beta | |
pull_request: {} | |
workflow_dispatch: {} | |
jobs: | |
test-and-release: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, '[skip ci]')" | |
strategy: | |
matrix: | |
node-version: [22.x] | |
concurrency: | |
group: ${{ github.ref }}-node-${{ matrix.node-version }} | |
cancel-in-progress: true | |
permissions: | |
# Necessary for semantic-release | |
contents: write | |
issues: write | |
pull-requests: write | |
# Necessary for npm publish --provenance | |
# See https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow | |
id-token: write | |
# packages: write is only necessary if you want to publish to Github | |
packages: write | |
steps: | |
- name: β¬οΈ Checkout repo | |
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # pin@main | |
- name: β Setup node ${{ matrix.node-version }} | |
uses: actions/setup-node@802632921f8532d2409ae6eac3313b6f81f11122 # pin@main | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
- name: π Cache node_modules | |
id: cache-node_modules | |
uses: actions/cache@36f1e144e1c8edb0a652766b484448563d8baf46 # pin@main | |
with: | |
path: "**/node_modules" | |
key: node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ | |
hashFiles('**/package-lock.json') }} | |
- name: π Cache .eslintcache | |
uses: actions/cache@36f1e144e1c8edb0a652766b484448563d8baf46 # pin@main | |
with: | |
path: .eslintcache | |
key: eslintcache-${{ runner.os }}-node-${{ matrix.node-version }}-${{ | |
hashFiles('**/package-lock.json') }} | |
- name: π₯ Install dependencies | |
if: steps.cache-node_modules.outputs.cache-hit != 'true' | |
run: | | |
npm ci --ignore-scripts | |
- name: π§ͺ Test | |
run: | | |
npm test | |
env: | |
CI: true | |
CLOCKODO_USER: ${{ secrets.CLOCKODO_USER }} | |
CLOCKODO_API_KEY: ${{ secrets.CLOCKODO_API_KEY }} | |
- name: β¬οΈ Upload coverage report | |
if: "matrix.node-version == '22.x'" | |
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # pin@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
# - RELEASE --------------------------------------------------------------------------------------- | |
- name: π Release on npm | |
if: "contains(' refs/heads/main refs/heads/beta ', github.ref) && | |
matrix.node-version == '22.x'" | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npm run release |