Publish Library Patch Version #3
Workflow file for this run
This file contains hidden or 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
name: Publish Library Patch 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 | |
registry-url: https://registry.npmjs.org/ | |
- name: Install all workspace dependencies | |
run: npm install | |
working-directory: . | |
- name: Bump patch version and create branch | |
run: | | |
cd library | |
# Bump version in library/package.json | |
npm version prepatch --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-patch-${new_version}" | |
git checkout -b "$branch_name" | |
# Configure git | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
# Add updated files | |
git add library/package.json package-lock.json | |
git commit -m "chore(release): bump prepatch 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 patch 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 }} |