|
| 1 | +name: Create Release PR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_bump: |
| 7 | + description: 'Version bump type' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + default: 'patch' |
| 15 | + |
| 16 | +jobs: |
| 17 | + create-release-pr: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout dev branch |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + ref: dev |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Get current version |
| 27 | + id: current_version |
| 28 | + run: | |
| 29 | + version=$(grep '^version:' deploy/helm/rag/Chart.yaml | awk '{print $2}') |
| 30 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + - name: Calculate new version |
| 33 | + id: new_version |
| 34 | + run: | |
| 35 | + current="${{ steps.current_version.outputs.version }}" |
| 36 | + IFS='.' read -r major minor patch <<< "$current" |
| 37 | +
|
| 38 | + case "${{ inputs.version_bump }}" in |
| 39 | + major) |
| 40 | + new_version="$((major + 1)).0.0" |
| 41 | + ;; |
| 42 | + minor) |
| 43 | + new_version="${major}.$((minor + 1)).0" |
| 44 | + ;; |
| 45 | + patch) |
| 46 | + new_version="${major}.${minor}.$((patch + 1))" |
| 47 | + ;; |
| 48 | + esac |
| 49 | +
|
| 50 | + echo "version=$new_version" >> $GITHUB_OUTPUT |
| 51 | + echo "New version will be: $new_version" |
| 52 | +
|
| 53 | + - name: Update Chart version |
| 54 | + run: | |
| 55 | + sed -i "s/^version: .*/version: ${{ steps.new_version.outputs.version }}/" deploy/helm/rag/Chart.yaml |
| 56 | + sed -i "s/^appVersion: .*/appVersion: \"${{ steps.new_version.outputs.version }}\"/" deploy/helm/rag/Chart.yaml |
| 57 | +
|
| 58 | + - name: Commit version bump |
| 59 | + run: | |
| 60 | + git config user.name "github-actions[bot]" |
| 61 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 62 | + git checkout -b release/v${{ steps.new_version.outputs.version }} |
| 63 | + git add deploy/helm/rag/Chart.yaml |
| 64 | + git commit -m "chore: bump version to ${{ steps.new_version.outputs.version }}" |
| 65 | + git push origin release/v${{ steps.new_version.outputs.version }} |
| 66 | +
|
| 67 | + - name: Create Pull Request |
| 68 | + env: |
| 69 | + GH_TOKEN: ${{ github.token }} |
| 70 | + run: | |
| 71 | + gh pr create \ |
| 72 | + --title "Release v${{ steps.new_version.outputs.version }}" \ |
| 73 | + --body "$(cat <<'EOF' |
| 74 | + ## Release v${{ steps.new_version.outputs.version }} |
| 75 | +
|
| 76 | + This PR merges changes from \`dev\` to \`main\` for release v${{ steps.new_version.outputs.version }}. |
| 77 | +
|
| 78 | + ### Changes |
| 79 | + $(git log main..dev --oneline --no-merges | head -20) |
| 80 | +
|
| 81 | + ### Checklist |
| 82 | + - [ ] All tests passing |
| 83 | + - [ ] Documentation updated |
| 84 | + - [ ] Breaking changes documented (if any) |
| 85 | +
|
| 86 | + After merging, this will automatically: |
| 87 | + - Create git tag v${{ steps.new_version.outputs.version }} |
| 88 | + - Build and push Docker images |
| 89 | + EOF |
| 90 | + )" \ |
| 91 | + --base main \ |
| 92 | + --head release/v${{ steps.new_version.outputs.version }} |
0 commit comments