Skip to content

Commit 86b4f89

Browse files
Create release-image.yaml
1 parent d254a6c commit 86b4f89

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Push Images to Quay
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: "Semantic version to release. Ex: major, minor, or patch"
8+
type: string
9+
required: true
10+
images:
11+
description: "List of image names. Example: csi-powerstore,csi-isilon"
12+
type: string
13+
required: true
14+
15+
jobs:
16+
push-images:
17+
if: ${{ inputs.version == 'patch' || inputs.version == 'minor' || inputs.version == 'major' }}
18+
name: Release images to Quay
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Push images to Quay.io
22+
shell: bash
23+
run: |
24+
images_list=$(echo '${{ inputs.images }}' | tr -d '[]"' | tr ',' ' ')
25+
REPOSITORY="dell/container-storage-modules"
26+
27+
for image in $images_list; do
28+
latest_version=$(curl -s https://quay.io/api/v1/repository/$REPOSITORY/$image/tag/?limit=100 | jq -r '.tags[].name' | sort -V | tail -n 1)
29+
echo "Current latest version of $image:$latest_version"
30+
31+
IFS='.' read -r -a version_parts <<< "$latest_version"
32+
33+
if "${{ inputs.version == 'major' }}"; then
34+
version_parts[0]=$(expr ${version_parts[0]} + 1)
35+
new_version="${version_parts[0]}.0.0"
36+
fi
37+
if "${{ inputs.version == 'minor' }}"; then
38+
version_parts[1]=$(expr ${version_parts[1]} + 1)
39+
new_version="${version_parts[0]}.${version_parts[1]}.0"
40+
fi
41+
if "${{ inputs.version == 'patch' }}"; then
42+
version_parts[2]=$(expr ${version_parts[2]} + 1)
43+
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
44+
fi
45+
46+
SHA=$(curl -s --location --request GET https://quay.io/api/v1/repository/$REPOSITORY/$image/tag?specificTag=nightly --header 'Content-Type: application/json' --header 'Authorization: Bearer ${{ secrets.QUAY_API_TOKEN }}' | jq -r '.tags[0].manifest_digest')
47+
echo "Pushing image: $image:$new_version"
48+
49+
curl --location --request PUT https://quay.io/api/v1/repository/$REPOSITORY/$image/tag/$new_version \
50+
--header 'Content-Type: application/json' \
51+
--header 'Authorization: Bearer ${{ secrets.QUAY_API_TOKEN }}' \
52+
--data-raw '{
53+
"manifest_digest": "'"$SHA"'"
54+
}'
55+
56+
curl --location --request PUT https://quay.io/api/v1/repository/$REPOSITORY/$image/tag/latest \
57+
--header 'Content-Type: application/json' \
58+
--header 'Authorization: Bearer ${{ secrets.QUAY_API_TOKEN }}' \
59+
--data-raw '{
60+
"manifest_digest": "'"$SHA"'"
61+
}'
62+
done

0 commit comments

Comments
 (0)