-
Notifications
You must be signed in to change notification settings - Fork 47
107 lines (92 loc) · 3.72 KB
/
Copy pathcreate-release-pr.yml
File metadata and controls
107 lines (92 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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 deploy/helm/rag/Chart.lock
git add deploy/helm/rag/Chart.yaml deploy/helm/rag/values.yaml deploy/helm/rag/Chart.lock
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 }}