Skip to content

Commit 0c9cbb9

Browse files
committed
add workflow release
1 parent 64c81cf commit 0c9cbb9

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

.github/workflows/release.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Release tag'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
build_and_push:
16+
runs-on: self-hosted
17+
strategy:
18+
matrix:
19+
include:
20+
- arch: amd64
21+
suffix: amd
22+
- arch: arm64
23+
suffix: arm
24+
25+
name: Building and push image for ${{ matrix.arch }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Get tag version
31+
id: get_version
32+
run: |
33+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
34+
echo "version=${{ inputs.tag }}" >> $GITHUB_OUTPUT
35+
else
36+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Add docker-credential-nebius to PATH
40+
run: echo "/home/helmrelease-trigger-operator/.nebius/bin" >> $GITHUB_PATH
41+
42+
- name: Build and push ${{ matrix.arch }} image
43+
run: |
44+
docker build \
45+
--platform linux/${{ matrix.arch }} \
46+
-t cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator:${{ steps.get_version.outputs.version }}-${{ matrix.suffix }} \
47+
-f Dockerfile .
48+
49+
docker push cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator:${{ steps.get_version.outputs.version }}-${{ matrix.suffix }}
50+
51+
create_multiarch_manifest:
52+
needs: build_and_push
53+
runs-on: self-hosted
54+
steps:
55+
- name: Get tag version
56+
id: get_version
57+
run: |
58+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
59+
echo "version=${{ inputs.tag }}" >> $GITHUB_OUTPUT
60+
else
61+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
62+
fi
63+
64+
- name: Add docker-credential-nebius to PATH
65+
run: echo "/home/helmrelease-trigger-operator/.nebius/bin" >> $GITHUB_PATH
66+
67+
- name: Create and push multi-arch manifest
68+
run: |
69+
docker manifest create \
70+
cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator:${{ steps.get_version.outputs.version }} \
71+
cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator:${{ steps.get_version.outputs.version }}-amd \
72+
cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator:${{ steps.get_version.outputs.version }}-arm
73+
74+
docker manifest push cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator:${{ steps.get_version.outputs.version }}
75+
76+
helm_release:
77+
needs: create_multiarch_manifest
78+
runs-on: self-hosted
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
83+
- name: Get tag version
84+
id: get_version
85+
run: |
86+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
87+
echo "version=${{ inputs.tag }}" >> $GITHUB_OUTPUT
88+
else
89+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
90+
fi
91+
92+
- name: Install Helm
93+
uses: azure/setup-helm@v3
94+
with:
95+
version: 'latest'
96+
97+
- name: Update Helm chart version and appVersion
98+
run: |
99+
VERSION=${{ steps.get_version.outputs.version }}
100+
# Remove 'v' prefix for Helm chart version (semantic versioning)
101+
CHART_VERSION=${VERSION#v}
102+
103+
# Update Chart.yaml with new version and appVersion
104+
sed -i "s/^version:.*/version: $CHART_VERSION/" helm/Chart.yaml
105+
sed -i "s/^appVersion:.*/appVersion: \"$VERSION\"/" helm/Chart.yaml
106+
107+
# Update image repository and tag in values.yaml
108+
sed -i "s|repository:.*|repository: cr.eu-north1.nebius.cloud/soperator/helmrelease-trigger-operator|" helm/values.yaml
109+
sed -i "s/tag:.*/tag: $VERSION/" helm/values.yaml
110+
111+
- name: Add docker-credential-nebius to PATH for Helm
112+
run: echo "/home/helmrelease-trigger-operator/.nebius/bin" >> $GITHUB_PATH
113+
114+
- name: Package and push Helm chart
115+
run: |
116+
VERSION=${{ steps.get_version.outputs.version }}
117+
CHART_VERSION=${VERSION#v}
118+
CHART_NAME="helmrelease-trigger-operator"
119+
CHART_TARGET="${CHART_NAME}-${CHART_VERSION}.tgz"
120+
RELEASE_PATH="."
121+
HELM_PATH="."
122+
OCI_REPO="oci://cr.eu-north1.nebius.cloud/soperator"
123+
124+
echo "Packaging chart ${CHART_NAME} as ${CHART_TARGET}."
125+
helm package -d "${RELEASE_PATH}" "${HELM_PATH}/helm"
126+
127+
echo "Pushing helm-${CHART_TARGET} to Container registry - ${OCI_REPO}"
128+
helm push "${RELEASE_PATH}/helm-${CHART_TARGET}" "${OCI_REPO}"

0 commit comments

Comments
 (0)