Skip to content

Publish Library Minor Version #1

Publish Library Minor Version

Publish Library Minor Version #1

name: Publish Library Minor Version
on:
workflow_dispatch:
jobs:
publish-patch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }} # Needed for pushing changes and creating PR
- uses: actions/setup-node@v4
with:
node-version: 22.14.0
registry-url: https://registry.npmjs.org/
- name: Set correct npm version
run: npm install -g npm@11.1.0
- name: Install all workspace dependencies
run: npm install
working-directory: .
- name: Bump Minor version and create branch
run: |
cd library
# Bump version in library/package.json
npm version preminor --no-git-tag-version --preid=alpha > /dev/null
new_version=$(node -p "require('./package.json').version")
echo "New version: $new_version"
# Go back to the root directory
cd ..
# Create and checkout new branch
branch_name="chore/version-bump-minor-${new_version}"
git checkout -b "$branch_name"
# Configure git
git config user.name "github-actions"
git config user.email "github-actions@github.com"
# Add updated files
git add library/package.json package-lock.json
git commit -m "chore(release): bump preminor version to $new_version"
git push origin "$branch_name"
# Set outputs
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
- name: Build library
run: npm run build
working-directory: library
- name: Publish to npm
run: npm publish --access public --tag latest
working-directory: library
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Pull Request
run: |
gh pr create \
--base main \
--head "${{ env.BRANCH_NAME }}" \
--title "chore: bump minor version to ${{ env.NEW_VERSION }}" \
--body "Automated version bump to ${{ env.NEW_VERSION }} and npm publish with alpha tag"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}