diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..03ddb7c --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,39 @@ +name: Deploy to NPM + +on: + push: + tags: + - 'v*' + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org/' + cache: 'yarn' + + - name: Install dependencies + run: yarn install + + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + + - name: Update package version + run: | + jq --arg v "$VERSION" '.version=$v' package.json > package.tmp.json + mv package.tmp.json package.json + + - name: Run prepare and build + run: yarn prepare + + - name: Publish package + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}