Skip to content

Commit 684bc07

Browse files
Add image version update workflow (#122)
* add image version update workflow * address review comments * update Readme * address review comment * fix readme * address review comments * address review comments related to README.md * remove extra space in README.md --------- Co-authored-by: Harish P <[email protected]>
1 parent 46c3b29 commit 684bc07

File tree

3 files changed

+206
-1
lines changed

3 files changed

+206
-1
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
name: Update image versions
10+
11+
# Invocable as a reusable workflow
12+
on:
13+
workflow_call:
14+
inputs:
15+
version:
16+
description: 'Version to release (major, minor, patch)'
17+
required: true
18+
type: string
19+
jobs:
20+
update-image-version:
21+
name: image-version-update
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout the code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Fetch the full history including the tags
28+
29+
- name: Set Dockerfile path based on repository
30+
id: set-dockerfile-path
31+
run: |
32+
if [[ "${{ github.repository }}" == "dell/csi-powermax" ]]; then
33+
echo "DOCKERFILE_PATHS=csireverseproxy/Dockerfile, Dockerfile" >> $GITHUB_ENV
34+
elif [[ "${{ github.repository }}" == "dell/csm-replication" ]]; then
35+
echo "DOCKERFILE_PATHS=Dockerfiles/Dockerfile" >> $GITHUB_ENV
36+
elif [[ "${{ github.repository }}" == "dell/csi-unity" ]]; then
37+
echo "DOCKERFILE_PATHS=Dockerfile.podman" >> $GITHUB_ENV
38+
else
39+
echo "DOCKERFILE_PATHS=Dockerfile" >> $GITHUB_ENV
40+
fi
41+
42+
- name: Debug Dockerfile path
43+
run: echo "DOCKERFILE_PATHS=${{ env.DOCKERFILE_PATHS }}"
44+
45+
- name: Set environment variables
46+
id: set-env-vars
47+
env:
48+
release_pattern: 'release="([0-9]+)\.([0-9]+)\.([0-9]+)"'
49+
version_pattern: 'version="([0-9]+)\.([0-9]+)\.([0-9]+)"'
50+
run: |
51+
IFS=',' read -r -a dockerfiles <<< "${{ env.DOCKERFILE_PATHS }}"
52+
for dockerfile in ${dockerfiles[@]}; do
53+
echo $dockerfile
54+
release_value=$(grep -oP 'release="\K([0-9]+)\.([0-9]+)\.([0-9]+)' $dockerfile)
55+
version_value=$(grep -oP 'version="\K([0-9]+)\.([0-9]+)\.([0-9]+)' $dockerfile)
56+
echo "release_value=$release_value" >> $GITHUB_ENV
57+
echo "version_value=$version_value" >> $GITHUB_ENV
58+
echo $version_value
59+
echo $release_value
60+
61+
# Strip 'v' prefix if exists
62+
current_version=${version_value#v}
63+
current_release=${release_value#v}
64+
65+
echo "current_version=$current_version"
66+
echo "current_release=$current_release"
67+
68+
IFS='.' read -r -a version_parts <<< "$current_version"
69+
IFS='.' read -r -a release_parts <<< "$current_release"
70+
71+
if [ "${{ inputs.version }}" = "major" ]; then
72+
# Major version bump up
73+
version_parts[0]=$(expr ${version_parts[0]} + 1)
74+
new_version="${version_parts[0]}.0.0"
75+
release_parts[0]=$(expr ${release_parts[0]} + 1)
76+
new_release="${release_parts[0]}.0.0"
77+
elif [ "${{ inputs.version }}" = "minor" ]; then
78+
# Minor version bump up
79+
version_parts[1]=$(expr ${version_parts[1]} + 1)
80+
new_version="${version_parts[0]}.${version_parts[1]}.0"
81+
release_parts[1]=$(expr ${release_parts[1]} + 1)
82+
new_release="${release_parts[0]}.${release_parts[1]}.0"
83+
elif [ "${{ inputs.version }}" = "patch" ]; then
84+
# Patch version bump up
85+
version_parts[2]=$(expr ${version_parts[2]} + 1)
86+
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
87+
release_parts[2]=$(expr ${release_parts[2]} + 1)
88+
new_release="${release_parts[0]}.${release_parts[1]}.${release_parts[2]}"
89+
else
90+
echo "Invalid version update type: ${{ inputs.version }}"
91+
exit 1
92+
fi
93+
94+
echo "New version to be released: v$new_version"
95+
echo "NEW_VERSION=v${new_version}" >> $GITHUB_ENV
96+
echo "New release will be: v$new_release"
97+
echo "NEW_RELEASE=v${new_release}" >> $GITHUB_ENV
98+
99+
# Print to verify values
100+
echo "NEW_VERSION=v${new_version}"
101+
echo "NEW_RELEASE=v${new_release}"
102+
103+
# Replace the version and release in Dockerfile
104+
sed -i "s/release=\"$release_value\"/release=\"$new_release\"/" $dockerfile
105+
sed -i "s/version=\"$version_value\"/version=\"$new_version\"/" $dockerfile
106+
done
107+
108+
# Needed for signing commits using Github App tokens
109+
# See: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#commit-signing
110+
- uses: actions/[email protected]
111+
id: generate-token
112+
with:
113+
app-id: ${{ vars.CSM_RELEASE_APP_ID }}
114+
private-key: ${{ secrets.CSM_RELEASE_APP_PRIVATE_KEY }}
115+
116+
# Must enable "allow GitHub Actions to create pull requests" setting
117+
# Author defaults to the user who triggered the workflow run
118+
- name: Create pull request
119+
uses: peter-evans/create-pull-request@v7
120+
with:
121+
token: ${{ steps.generate-token.outputs.token }}
122+
branch: "updateImage-${{ env.NEW_VERSION }}"
123+
commit-message: "Update image version and release version"
124+
title: "Update image version to ${{ env.NEW_VERSION }} and release version to ${{ env.NEW_RELEASE }}"
125+
body: |
126+
Image version updated to ${{ env.NEW_VERSION }}
127+
Auto-generated by [common-github-actions](https://github.com/dell/common-github-actions)
128+
sign-commits: true
129+
delete-branch: true
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Trigger workflow for go version update on CSM projects
10+
name: Trigger Image Version Workflow
11+
12+
on:
13+
workflow_dispatch:
14+
15+
jobs:
16+
trigger:
17+
name: Trigger Image Version Update
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
repo:
23+
[
24+
dell/csi-powerscale
25+
dell/csi-powermax
26+
dell/csi-powerflex
27+
dell/csi-powerstore
28+
dell/csi-unity
29+
dell/csm-metrics-powermax
30+
dell/csm-metrics-powerscale
31+
dell/csm-metrics-powerstore
32+
dell/csm-operator
33+
dell/csm-replication
34+
dell/karavi-metrics-powerflex
35+
dell/karavi-resiliency
36+
dell/karavi-topology
37+
dell/karavi-authorization
38+
]
39+
40+
steps:
41+
- name: Trigger Image Version Update
42+
uses: peter-evans/repository-dispatch@v3
43+
with:
44+
# For token information, see: https://github.com/peter-evans/repository-dispatch/tree/main?tab=readme-ov-file#token
45+
token: ${{ secrets.CSMBOT_PAT }}
46+
repository: ${{ matrix.repo }}
47+
event-type: image-update-workflow
48+
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,35 @@ jobs:
266266
secrets: inherit
267267
```
268268
269+
### image-update-workflow
270+
271+
This workflow automates the image and release version update in Dockerfiles. The workflow accepts one parameter - Version to release (major, minor, patch).
272+
The manual workflow is recommended to be used for out of band releases such as patch releases or when the increment is a major version change.
273+
274+
For manual trigger from driver and module repositories, here is the example for the csi-powerscale repo:
275+
276+
```yaml
277+
name: Image Version Update
278+
279+
on: # yamllint disable-line rule:truthy
280+
workflow_dispatch:
281+
inputs:
282+
version:
283+
description: "Version to release (major, minor, patch) Ex: minor"
284+
required: true
285+
repository_dispatch:
286+
types: [image-update-workflow]
287+
288+
jobs:
289+
# image version update
290+
image-version-update:
291+
uses: dell/common-github-actions/.github/workflows/image-version-workflow.yaml@main
292+
with:
293+
version: "${{ github.event.inputs.version || 'minor' }}"
294+
secrets: inherit
295+
296+
```
297+
=======
269298
## csm-operator version update to latest
270299
This workflow updates csm-operator repository with latest version of the operator for the given release.
271300
It also updates the CSM program version wherever it is used in csm-operator repository.
@@ -357,7 +386,6 @@ jobs:
357386
resizer: ${{ inputs.resizer }}
358387
sdcmonitor: ${{ inputs.sdcmonitor }}
359388
secrets: inherit
360-
361389
```
362390

363391
## Support

0 commit comments

Comments
 (0)