version(minor): added suffix node property for root bucket field item #4
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
name: Build and Publish React Component Library | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '14' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install | |
- name: Extract last commit message | |
id: commit_message | |
run: echo "message=$(git log -1 --pretty=%B)" >> $GITHUB_ENV | |
- name: Determine version bump | |
id: version_bump | |
run: | | |
COMMIT_MESSAGE="${{ env.message }}" | |
if [[ "$COMMIT_MESSAGE" =~ version\(minor\):(.*) ]]; then | |
echo "type=minor" >> $GITHUB_ENV | |
echo "msg=${BASH_REMATCH[1]}" >> $GITHUB_ENV | |
elif [[ "$COMMIT_MESSAGE" =~ version\(major\):(.*) ]]; then | |
echo "type=major" >> $GITHUB_ENV | |
echo "msg=${BASH_REMATCH[1]}" >> $GITHUB_ENV | |
elif [[ "$COMMIT_MESSAGE" =~ version\(patch\):(.*) ]]; then | |
echo "type=patch" >> $GITHUB_ENV | |
echo "msg=${BASH_REMATCH[1]}" >> $GITHUB_ENV | |
else | |
echo "No version bump found in commit message." | |
exit 0 | |
fi | |
- name: Configure Git | |
run: | | |
git config --global user.name "ThayalanGR" | |
git config --global user.email "[email protected]" | |
- name: Bump version | |
run: | | |
if [ "${{ env.type }}" == "minor" ]; then | |
npm version minor -m "Version bump: ${{ env.msg }}" | |
elif [ "${{ env.type }}" == "major" ]; then | |
npm version major -m "Version bump: ${{ env.msg }}" | |
elif [ "${{ env.type }}" == "patch" ]; then | |
npm version patch -m "Version bump: ${{ env.msg }}" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the library | |
run: yarn build:library | |
- name: Install npm with logging | |
run: | | |
npm install -g npm@latest | |
npm --version | |
- name: Publish to npm with retries | |
run: | | |
retry_count=0 | |
max_retries=5 | |
delay=30 | |
while [ $retry_count -lt $max_retries ]; do | |
npm publish && break | |
retry_count=$((retry_count+1)) | |
echo "Publish failed. Retrying in $delay seconds..." | |
sleep $delay | |
done | |
if [ $retry_count -eq $max_retries ]; then | |
echo "Publish failed after $max_retries attempts." | |
exit 1 | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Push new tags | |
run: git push --follow-tags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |