Repository navigation
128 lines (110 loc) · 4.14 KB
/
Copy pathhelm-package.yml
File metadata and controls
128 lines (110 loc) · 4.14 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Copyright 2024 RustFS Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Publish helm chart to artifacthub
on:
workflow_run:
workflows: [ "Publish Docker Image" ]
types: [ completed ]
workflow_dispatch:
inputs:
version:
description: "Release version to publish, e.g. 1.0.0 or v1.0.0"
required: true
type: string
permissions:
contents: read
jobs:
build-helm-package:
runs-on: sm-standard-2
if: |
github.event_name == 'workflow_dispatch' ||
(
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'release' &&
contains(github.event.workflow_run.head_branch, '.')
)
outputs:
raw_tag: ${{ steps.version.outputs.raw_tag }}
chart_version: ${{ steps.version.outputs.chart_version }}
steps:
- name: Normalize release version
id: version
env:
RELEASE_TAG: ${{ inputs.version || github.event.workflow_run.head_branch }}
run: |
set -euo pipefail
RAW_TAG="${RELEASE_TAG#refs/tags/}"
git check-ref-format "refs/tags/$RAW_TAG"
CHART_VERSION="${RAW_TAG#v}"
if [ -z "$CHART_VERSION" ]; then
echo "Version is empty"
exit 1
fi
{
echo "raw_tag=$RAW_TAG"
echo "chart_version=$CHART_VERSION"
} >> "$GITHUB_OUTPUT"
- name: Check out the release source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.event.workflow_run.head_sha || format('refs/tags/{0}', steps.version.outputs.raw_tag) }}
- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
- name: Package Helm Chart
env:
CHART_VERSION: ${{ steps.version.outputs.chart_version }}
run: |
set -eux
helm package ./deploy/rustfs-operator \
--destination helm-packages/ \
--version "$CHART_VERSION" \
--app-version "$CHART_VERSION"
helm package ./deploy/rustfs-tenant \
--destination helm-packages/ \
--version "$CHART_VERSION"
- name: Upload helm package as artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: helm-package
path: helm-packages/*.tgz
retention-days: 1
publish-helm-package:
runs-on: sm-standard-2
needs: [ build-helm-package ]
if: needs.build-helm-package.result == 'success'
steps:
- name: Checkout helm package repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
repository: rustfs/operator-helm-package
token: ${{ secrets.RUSTFS_HELM_PACKAGE }}
- name: Download helm package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: helm-package
path: ./
- name: Set up helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
- name: Generate index
run: helm repo index . --url https://operator.rustfs.com
- name: Push helm package and index file
env:
CHART_VERSION: ${{ needs.build-helm-package.outputs.chart_version }}
run: |
set -eux
git config --global user.name "${{ secrets.USERNAME }}"
git config --global user.email "${{ secrets.EMAIL_ADDRESS }}"
git add .
git commit -m "Update rustfs operator helm package with $CHART_VERSION." || echo "No changes to commit"
git push origin main