Create Release PR #9
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 Release PR | |
| on: | |
| workflow_dispatch: | |
| branches: | |
| - dev | |
| inputs: | |
| version_bump: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: 'patch' | |
| jobs: | |
| create-release-pr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout dev branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: dev | |
| fetch-depth: 0 | |
| - name: Get current version | |
| id: current_version | |
| run: | | |
| # Get version from main branch since that's the source of truth for releases | |
| git fetch origin main | |
| version=$(git show origin/main:deploy/helm/rag/Chart.yaml | grep '^version:' | awk '{print $2}') | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| - name: Calculate new version | |
| id: new_version | |
| run: | | |
| current="${{ steps.current_version.outputs.version }}" | |
| IFS='.' read -r major minor patch <<< "$current" | |
| case "${{ inputs.version_bump }}" in | |
| major) | |
| new_version="$((major + 1)).0.0" | |
| ;; | |
| minor) | |
| new_version="${major}.$((minor + 1)).0" | |
| ;; | |
| patch) | |
| new_version="${major}.${minor}.$((patch + 1))" | |
| ;; | |
| esac | |
| echo "version=$new_version" >> $GITHUB_OUTPUT | |
| echo "New version will be: $new_version" | |
| - name: Update Chart version | |
| run: | | |
| sed -i "s/^version: .*/version: ${{ steps.new_version.outputs.version }}/" deploy/helm/rag/Chart.yaml | |
| sed -i "s/^appVersion: .*/appVersion: \"${{ steps.new_version.outputs.version }}\"/" deploy/helm/rag/Chart.yaml | |
| - name: Update image tag to use release version | |
| run: | | |
| sed -i "s/tag: .*/tag: ${{ steps.new_version.outputs.version }}/" deploy/helm/rag/values.yaml | |
| - name: Commit version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout -b release/v${{ steps.new_version.outputs.version }} | |
| git add deploy/helm/rag/Chart.yaml deploy/helm/rag/values.yaml | |
| git commit -m "chore: bump version to ${{ steps.new_version.outputs.version }}" | |
| # Merge main into release branch to pre-resolve conflicts | |
| git fetch origin main | |
| git merge origin/main --no-edit || { | |
| # If conflicts occur, take our (release branch) version for Chart.yaml and values.yaml | |
| git checkout --ours deploy/helm/rag/Chart.yaml deploy/helm/rag/values.yaml | |
| git add deploy/helm/rag/Chart.yaml deploy/helm/rag/values.yaml | |
| git commit --no-edit | |
| } | |
| git push origin release/v${{ steps.new_version.outputs.version }} | |
| - name: Create Pull Request | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh pr create \ | |
| --title "Release v${{ steps.new_version.outputs.version }}" \ | |
| --body "## Release v${{ steps.new_version.outputs.version }} | |
| This PR merges changes from \`dev\` to \`main\` for release v${{ steps.new_version.outputs.version }}. | |
| ### Checklist | |
| - [ ] All tests passing | |
| - [ ] Documentation updated | |
| - [ ] Breaking changes documented (if any) | |
| After merging, this will automatically: | |
| - Create git tag v${{ steps.new_version.outputs.version }} | |
| - Build and push container images" \ | |
| --base main \ | |
| --head release/v${{ steps.new_version.outputs.version }} |