Skip to content

chore: bump version to v1.2.6 #42

chore: bump version to v1.2.6

chore: bump version to v1.2.6 #42

Workflow file for this run

name: Release
on:
push:
branches: [master]
jobs:
check-version-bump:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
outputs:
is_version_bump: ${{ steps.check_version_bump.outputs.is_version_bump }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Check if version bump commit
id: check_version_bump
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
echo "Last commit message: $COMMIT_MESSAGE"
if echo "$COMMIT_MESSAGE" | grep -q "^chore: bump version to "; then
echo "is_version_bump=true" >> $GITHUB_OUTPUT
echo "Skipping pipeline - this is a version bump commit"
else
echo "is_version_bump=false" >> $GITHUB_OUTPUT
echo "Proceeding with pipeline - not a version bump commit"
fi
release:
runs-on: ubuntu-latest
needs: check-version-bump
if: needs.check-version-bump.outputs.is_version_bump == 'false'
steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.DEPLOYMENT_APP_ID }}
private-key: ${{ secrets.DEPLOYMENT_APP_SECRET }}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Get previous version
id: prev_version
run: |
PREV_VERSION=$(node -p "require('./package.json').version")
echo "prev_version=$PREV_VERSION" >> $GITHUB_OUTPUT
echo "Previous version: $PREV_VERSION"
- name: Analyze conventional commits and determine version bump
id: version_bump
run: |
# Get commits since last tag (these are the commits that were merged from development to master)
LAST_TAG=$(git tag --sort=-version:refname | head -1)
if [ -n "$LAST_TAG" ]; then
echo "Using commits since last tag: $LAST_TAG"
COMMITS=$(git log --oneline $LAST_TAG..HEAD --pretty=format:"%s")
else
# If no tags exist, get all commits (first release)
echo "No tags found, using all commits for first release"
COMMITS=$(git log --oneline --pretty=format:"%s")
fi
echo "Analyzing conventional commits:"
echo "$COMMITS"
# Check for feat commits (minor bump)
FEAT_COUNT=$(echo "$COMMITS" | grep -c "^feat" || true)
# Check for fix commits (patch bump)
FIX_COUNT=$(echo "$COMMITS" | grep -c "^fix" || true)
echo "feat count: $FEAT_COUNT"
echo "fix count: $FIX_COUNT"
echo "feat commits: $FEAT_COUNT"
echo "fix commits: $FIX_COUNT"
if [ "$FEAT_COUNT" -gt 0 ]; then
echo "bump_type=minor" >> $GITHUB_OUTPUT
echo "Version bump: minor (feat commits found)"
elif [ "$FIX_COUNT" -gt 0 ]; then
echo "bump_type=patch" >> $GITHUB_OUTPUT
echo "Version bump: patch (fix commits found)"
else
echo "bump_type=none" >> $GITHUB_OUTPUT
echo "No version bump needed (no feat/fix commits)"
fi
- name: Bump version
if: steps.version_bump.outputs.bump_type != 'none'
id: bump_version
run: |
BUMP_TYPE="${{ steps.version_bump.outputs.bump_type }}"
echo "Bumping $BUMP_TYPE version..."
# Bump version using npm version
NEW_VERSION=$(npm version $BUMP_TYPE --no-git-tag-version)
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
- name: Generate changelog
id: changelog
run: |
# Get commits since last tag (these are the commits that were merged from development to master)
LAST_TAG=$(git tag --sort=-version:refname | head -1)
if [ -n "$LAST_TAG" ]; then
COMMITS=$(git log $LAST_TAG..HEAD --pretty=format:"- %s (%h)" --grep="^feat\|^fix\|^docs\|^style\|^refactor\|^perf\|^test\|^chore\|^build\|^revert" --no-merges)
else
COMMITS=$(git log --pretty=format:"- %s (%h)" --grep="^feat\|^fix\|^docs\|^style\|^refactor\|^perf\|^test\|^chore\|^build\|^revert" --no-merges)
fi
# Generate changelog header
CHANGELOG_HEADER="## Changes in ${{ steps.bump_version.outputs.new_version || steps.prev_version.outputs.prev_version }}"
CHANGELOG_FOOTER="**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.prev_version.outputs.prev_version }}...${{ steps.bump_version.outputs.new_version || steps.prev_version.outputs.prev_version }}"
# Combine all parts
CHANGELOG="${CHANGELOG_HEADER}\n\n${COMMITS}\n\n${CHANGELOG_FOOTER}"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo -e "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Generated changelog:"
echo -e "$CHANGELOG"
- name: Build project
run: |
yarn build
echo "Build completed successfully"
- name: Commit version bump
if: steps.version_bump.outputs.bump_type != 'none'
run: |
git add package.json
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
git push origin master
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Create Git tag
if: steps.version_bump.outputs.bump_type != 'none'
run: |
git tag -a "${{ steps.bump_version.outputs.new_version }}" -m "Release ${{ steps.bump_version.outputs.new_version }}"
git push origin "${{ steps.bump_version.outputs.new_version }}"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Create GitHub Release
if: steps.version_bump.outputs.bump_type != 'none'
run: |
gh release create "${{ steps.bump_version.outputs.new_version }}" \
--title "Release ${{ steps.bump_version.outputs.new_version }}" \
--notes "${{ steps.changelog.outputs.changelog }}"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Publish to npm
if: steps.version_bump.outputs.bump_type != 'none'
run: |
echo "Publishing to npm..."
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}