v3.3.1 #12
Workflow file for this run
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: Publish Package to npm | |
on: | |
release: | |
types: [published, edited] | |
# Prevent multiple releases from running simultaneously | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'pnpm' | |
# Cache dependencies | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
# Cache test coverage | |
- name: Cache coverage | |
uses: actions/cache@v4 | |
with: | |
path: ./coverage | |
key: ${{ runner.os }}-coverage-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-coverage- | |
- name: Run tests with coverage | |
run: pnpm test:coverage | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
directory: ./coverage | |
flags: unittests | |
name: codecov-umbrella | |
verbose: true | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'pnpm' | |
# Cache dependencies | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
# Cache build output | |
- name: Cache build | |
uses: actions/cache@v4 | |
with: | |
path: ./dist | |
key: ${{ runner.os }}-build-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-build- | |
- name: Verify package version | |
run: | | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then | |
echo "Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)" | |
exit 1 | |
fi | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run build | |
run: pnpm build | |
- name: Publish to npm | |
run: pnpm publish --no-git-checks --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_CONFIG_PROVENANCE: true |