-
Notifications
You must be signed in to change notification settings - Fork 6
235 lines (203 loc) · 7.53 KB
/
pipeline.yaml
File metadata and controls
235 lines (203 loc) · 7.53 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Pipeline
on:
push:
branches:
- "**" # Matches all branches
pull_request:
branches:
- "**" # Matches all branches
workflow_dispatch:
inputs:
force_build:
description: "Forces a build even if no changes are detected"
required: true
default: "false"
force_release:
description: "Forces a release even if no changes are detected"
required: true
default: "false"
concurrency:
group: pipeline-${{ github.ref_name }}
cancel-in-progress: true
env:
helm_chart_repository: "ghcr.io/emberstack/helm-charts"
helm_chart_repository_protocol: "oci://"
jobs:
discovery:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
pathsFilter_src: ${{ steps.pathsFilter.outputs.src }}
gitVersion_SemVer: ${{ steps.gitversion.outputs.GitVersion_SemVer }}
gitVersion_AssemblySemFileVer: ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }}
build: ${{ steps.evaluate_build.outputs.result }}
build_configuration: ${{ steps.evaluate_build_configuration.outputs.result }}
release: ${{ steps.evaluate_release.outputs.result }}
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: tools - dotnet - install
uses: actions/setup-dotnet@v5
with:
dotnet-version: "9.x"
- name: tools - gitversion - install
uses: gittools/actions/gitversion/setup@v4.5.0
with:
versionSpec: "6.x"
preferLatestVersion: true
- name: gitversion - execute
id: gitversion
uses: gittools/actions/gitversion/execute@v4.5.0
with:
configFilePath: GitVersion.yaml
- name: tools - detect changes
id: pathsFilter
uses: dorny/paths-filter@v4
with:
base: ${{ github.ref }}
filters: |
src:
- '*.sln'
- '*.slnx'
- '*.props'
- 'src/**'
build:
- '*.sln'
- '*.slnx'
- '*.props'
- 'src/**'
- 'tests/**'
- 'playground/**'
- name: evaluate - build
id: evaluate_build
run: |
if [ "${{ steps.pathsFilter.outputs.build }}" = "true" ] || \
[ "${{ github.event.inputs.force_build }}" = "true" ] || \
[ "${{ github.event.inputs.force_release }}" = "true" ]; then
result=true
else
result=false
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: evaluate - build_configuration
id: evaluate_build_configuration
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
result=Release
else
result=Debug
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: evaluate - release
id: evaluate_release
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ] || \
[ "${{ github.event.inputs.force_release }}" = "true" ]; then
result=true
else
result=false
fi
echo "result=$result" >> $GITHUB_OUTPUT
build:
name: build
if: ${{ needs.discovery.outputs.build == 'true' }}
needs: [discovery]
runs-on: ubuntu-latest
env:
build: ${{ needs.discovery.outputs.build }}
build_configuration: ${{ needs.discovery.outputs.build_configuration }}
gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }}
gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
steps:
- name: checkout
uses: actions/checkout@v6
- name: artifacts - prepare directories
run: |
mkdir -p .artifacts/helm
mkdir -p .artifacts/helm/repository
mkdir -p .artifacts/kubectl
- name: tools - helm - install
uses: azure/setup-helm@v5
- name: helm - dependency build
run: |
for dir in src/charts/*; do
[ -d "$dir" ] || continue
if [ -f "$dir/Chart.lock" ] || grep -q '^dependencies:' "$dir/Chart.yaml" 2>/dev/null; then
helm dependency build "$dir"
fi
done
- name: helm - package
run: |
for dir in src/charts/*; do
[ -d "$dir" ] || continue
helm_chart=$(basename "$dir")
dest_dir=".artifacts/helm"
mkdir -p "$dest_dir"
app_version=$(grep '^appVersion:' "$dir/Chart.yaml" | awk '{print $2}' | tr -d '"')
if [ -z "$app_version" ]; then
app_version="${{ env.gitVersion_SemVer }}"
fi
helm package "$dir" --destination "$dest_dir" --version ${{ env.gitVersion_SemVer }} --app-version "$app_version"
echo "Packaged $helm_chart (appVersion: $app_version) to $dest_dir"
done
- name: artifacts - helm - upload
uses: actions/upload-artifact@v7
with:
name: artifacts-helm-${{env.gitVersion_SemVer}}
path: .artifacts/helm
release:
name: release
if: ${{ needs.discovery.outputs.release == 'true' && github.ref == 'refs/heads/main' }}
needs: [discovery, build]
runs-on: ubuntu-latest
env:
gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }}
gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
steps:
- name: artifacts - helm - download
uses: actions/download-artifact@v8
with:
name: artifacts-helm-${{env.gitVersion_SemVer}}
path: .artifacts/helm
- name: tools - helm - install
uses: azure/setup-helm@v5
- name: tools - helm - login - ghcr.io
run: echo "${{ secrets.ES_GITHUB_PAT }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: tools - oras - install
uses: oras-project/setup-oras@v2
- name: tools - oras - login - ghcr.io
run: echo "${{ secrets.ES_GITHUB_PAT }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Find and inspect all .tgz Helm charts in .artifacts/helm
run: |
set -euo pipefail
echo "🔍 Searching for .tgz Helm charts in '.artifacts/helm/'..."
find .artifacts/helm -type f -name '*.tgz' | while read -r chart; do
echo "📦 Chart file: $chart"
# Extract chart metadata
metadata=$(helm show chart "$chart")
name=$(echo "$metadata" | awk '/^name:/ { print $2 }')
version=$(echo "$metadata" | awk '/^version:/ { print $2 }')
echo " → Name: $name"
echo " → Version: $version"
helm push "$chart" ${{ env.helm_chart_repository_protocol }}${{ env.helm_chart_repository }}
done
- name: github - release - create
uses: softprops/action-gh-release@v3
with:
repository: ${{ github.repository }}
name: v${{ env.gitVersion_SemVer }}
tag_name: v${{ env.gitVersion_SemVer }}
body: The release process is automated.
generate_release_notes: true
token: ${{ secrets.ES_GITHUB_PAT }}
- name: github - repository-dispatch - release
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.ES_GITHUB_PAT }}
repository: emberstack/helm-charts
event-type: release
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'