-
Notifications
You must be signed in to change notification settings - Fork 10
83 lines (68 loc) · 2.96 KB
/
update-on-version.yml
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
name: update on version change
on:
pull_request:
paths:
- "charts/perses/Chart.yaml"
types: [opened, labeled, synchronize]
jobs:
update-chart-version:
name: Update Chart Version
if: contains(github.event.pull_request.labels.*.name, 'dependencies')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 2
- name: Install yq for YAML processing
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
- name: Process Chart version update
id: version-update
run: |
# Check if appVersion changed in the latest commit
if git diff HEAD^ HEAD -- charts/perses/Chart.yaml | grep -q '^[+-].*appVersion:'; then
echo "appVersion change detected - updating Chart version"
echo "version_changed=true" >> $GITHUB_OUTPUT
# Extract current version from Chart.yaml
current_version=$(yq e '.version' charts/perses/Chart.yaml)
echo "Current Chart version: $current_version"
# Split version into components
IFS='.' read -r major minor patch <<< "$current_version"
# Increment minor version and reset patch
new_version="${major}.$((minor + 1)).0"
echo "New Chart version will be: $new_version"
# Update version in Chart.yaml
yq e ".version = \"$new_version\"" -i charts/perses/Chart.yaml
echo "Successfully updated Chart.yaml version"
else
echo "No appVersion change detected - skipping version update"
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Setup Go development environment
if: steps.version-update.outputs.version_changed == 'true'
uses: ./.github/actions/setup_environment
with:
enable_go: true
- name: Install mdox documentation tool
if: steps.version-update.outputs.version_changed == 'true'
run: go install github.com/bwplotka/mdox@latest
- name: Generate documentation and assets
if: steps.version-update.outputs.version_changed == 'true'
run: make update-helm-readme
- name: Commit and push changes
if: steps.version-update.outputs.version_changed == 'true'
run: |
# Configure git user for commit
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Stage all changes
git add .
# Commit and push if there are changes
git commit -m "chore: bump chart version and update generated files" || echo "No changes to commit"
git push