Merge pull request #6 from treedomtrees/chore/update-pipeline #9
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
# Publish to NPM if a new tag with format [mypackage/v1.1.1] is created | |
name: Publish package to registry | |
on: | |
push: | |
tags: | |
- "*/v[0-9]+.[0-9]+.[0-9]+" | |
- "*/v[0-9]+.[0-9]+.[0-9]+-*" | |
jobs: | |
publish: | |
name: Publish Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '22.x' | |
registry-url: 'https://registry.npmjs.org' | |
- run: | | |
echo 'package_name=${{ github.ref }}' | sed -E "s:refs/tags/(.+)/v.+$:\1:" >> $GITHUB_ENV | |
echo 'package_version=${{ github.ref }}' | sed -E "s:refs/tags/.+/(v.+)$:\1:" >> $GITHUB_ENV | |
- name: Bumping version | |
run: npm version ${{ env.package_version }} --workspace packages/${{ env.package_name }} | |
- name: Install dependencies | |
run: npm install --workspace packages/${{ env.package_name }} | |
- name: Publish to registry | |
run: npm publish --workspace packages/${{ env.package_name }} --if-present --provenance | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.TREEDOM_NPMJS_TOKEN }} | |
- name: Commit version | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "chore: bump ${{ env.package_name }} to version ${{ env.package_version }}" || echo "No changes to commit" | |
- name: Push to main | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |