Create Version Bump PR #77
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: "Create Version Bump PR" | |
| on: | |
| schedule: | |
| - cron: '0 3 * * MON' # Each Monday at 3am UTC | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| type: choice | |
| description: "Version bump type" | |
| required: true | |
| default: patch | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| create-pr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Hatch | |
| run: | | |
| pip install hatch 'virtualenv!=21.0.0' | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Calculate next version | |
| id: version | |
| working-directory: ./datajunction-server | |
| run: | | |
| CURRENT_VERSION=$(hatch version) | |
| echo "Current version: $CURRENT_VERSION" | |
| BUMP_TYPE="${{ github.event.inputs.bump || 'patch' }}" | |
| echo "Bump type: $BUMP_TYPE" | |
| # Parse current version (handles X.Y.Z and X.Y.ZaN formats) | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "${CURRENT_VERSION%%a*}" | |
| # Calculate new version | |
| case $BUMP_TYPE in | |
| major) NEW_VERSION="$((MAJOR + 1)).0.0" ;; | |
| minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;; | |
| patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; | |
| esac | |
| echo "New version: $NEW_VERSION" | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Configure Git | |
| run: | | |
| git config user.name "GitHub Actions Bot" | |
| git config user.email "actions@github.com" | |
| - name: Create release branch and update versions | |
| run: | | |
| VERSION="${{ steps.version.outputs.NEW_VERSION }}" | |
| BRANCH="release/v$VERSION" | |
| git checkout -b $BRANCH | |
| # Update Python packages | |
| cd datajunction-server && hatch version $VERSION && cd .. | |
| cd datajunction-query && hatch version $VERSION && cd .. | |
| cd datajunction-reflection && hatch version $VERSION && cd .. | |
| cd datajunction-clients/python && hatch version $VERSION && cd ../.. | |
| # Update JavaScript packages | |
| cd datajunction-ui && npm version $VERSION --no-git-tag-version && cd .. | |
| cd datajunction-clients/javascript && npm version $VERSION --no-git-tag-version && cd ../.. | |
| git add -A | |
| git commit -m "Bump version to v$VERSION" | |
| git push origin $BRANCH | |
| - name: Create Pull Request | |
| run: | | |
| VERSION="${{ steps.version.outputs.NEW_VERSION }}" | |
| gh pr create \ | |
| --title "Release v$VERSION" \ | |
| --body "## Release v$VERSION | |
| This PR bumps all package versions to v$VERSION. | |
| **When merged**, packages will be automatically published to: | |
| - PyPI: datajunction-server, datajunction-query, datajunction-reflection, datajunction | |
| - npm: datajunction, datajunction-ui | |
| A GitHub Release will also be created with auto-generated release notes. | |
| --- | |
| *Auto-generated by Create Version Bump workflow*" \ | |
| --base main \ | |
| --head "release/v$VERSION" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }} | |
| - name: Summary | |
| run: | | |
| VERSION="${{ steps.version.outputs.NEW_VERSION }}" | |
| echo "## Version Bump PR Created" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** v$VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Review the PR and merge when ready to publish." >> $GITHUB_STEP_SUMMARY |