name: Automatic Version Bump on: push: branches: - main workflow_dispatch: inputs: version_type: description: 'Version bump type' required: true default: 'patch' type: choice options: - patch - minor - major jobs: version-bump: runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Configure Git run: | git config --global user.name "GitHub Actions Bot" git config --global user.email "actions@github.com" - name: Determine version type id: version_type run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then echo "type=${{ github.event.inputs.version_type }}" >> $GITHUB_OUTPUT else # Auto-detect version type based on commit message COMMIT_MSG="${{ github.event.head_commit.message }}" if [[ "$COMMIT_MSG" == *"BREAKING CHANGE"* ]] || [[ "$COMMIT_MSG" == *"!"* ]]; then echo "type=major" >> $GITHUB_OUTPUT elif [[ "$COMMIT_MSG" == *"feat:"* ]] || [[ "$COMMIT_MSG" == *"feat("* ]]; then echo "type=minor" >> $GITHUB_OUTPUT else echo "type=patch" >> $GITHUB_OUTPUT fi fi - name: Bump Frontend Version id: frontend_version working-directory: ./frontend run: | npm version ${{ steps.version_type.outputs.type }} --no-git-tag-version NEW_VERSION=$(node -p "require('./package.json').version") echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT - name: Bump Backend Version id: backend_version working-directory: ./backend run: | npm version ${{ steps.version_type.outputs.type }} --no-git-tag-version NEW_VERSION=$(node -p "require('./package.json').version") echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT - name: Update Frontend VersionInfo component run: | VERSION=${{ steps.frontend_version.outputs.version }} sed -i "s/const FRONTEND_VERSION = '[^']*'/const FRONTEND_VERSION = '$VERSION'/" frontend/src/components/admin/VersionInfo.tsx - name: Create Pull Request uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: bump version to ${{ steps.frontend_version.outputs.version }}" title: "chore: bump version to ${{ steps.frontend_version.outputs.version }}" body: | ## Version Bump This PR automatically bumps the version numbers: - Frontend: `${{ steps.frontend_version.outputs.version }}` - Backend: `${{ steps.backend_version.outputs.version }}` ### Version Type: ${{ steps.version_type.outputs.type }} ### Files Changed: - `frontend/package.json` - `backend/package.json` - `frontend/src/components/admin/VersionInfo.tsx` --- *This PR was automatically created by the version bump workflow.* branch: version-bump-${{ steps.frontend_version.outputs.version }} delete-branch: true labels: | version-bump automated