Skip to content

Merge pull request #6 from treedomtrees/chore/update-pipeline #9

Merge pull request #6 from treedomtrees/chore/update-pipeline

Merge pull request #6 from treedomtrees/chore/update-pipeline #9

Workflow file for this run

# 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