Skip to content

Commit

Permalink
Add GitHub Actions workflow to publish to NPM
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jun 29, 2023
1 parent 9b1fca5 commit 8182ecc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean install of node dependencies and run tests
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: CI

on:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish

on:
release:
types: [published]

permissions:
id-token: write

jobs:
publish:
name: Publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cache .yarn/cache
uses: actions/cache@v3
env:
cache-name: yarn-cache
with:
path: .yarn/cache
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn --immutable
env:
HUSKY: 0

- name: Publish with latest tag
if: github.event.release.prelease == false
run: yarn npm publish --tag latest
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish with next tag
if: github.event.release.prelease == true
run: yarn npm publish --tag next
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"vitest": "^0.30.1"
},
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"files": [
"dist",
Expand Down

0 comments on commit 8182ecc

Please sign in to comment.