-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (109 loc) · 4.02 KB
/
Copy pathrelease.yml
File metadata and controls
124 lines (109 loc) · 4.02 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
name: Create Beta Release
on:
push:
branches:
- main
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
outputs:
# Expose matched filters as job 'packages' output variable
charts: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
argocd: charts/argocd/**
aws: charts/aws/**
azure: charts/azure/**
flux: charts/flux/**
gcp: charts/gcp/**
kubernetes: charts/kubernetes/**
kubernetes-view: charts/kubernetes-view/**
mission-control: charts/mission-control/**
mongo-atlas: charts/mongo-atlas/**
postgres: charts/postgres/**
prometheus: charts/prometheus/**
playbooks-kubernetes: charts/playbooks-kubernetes/**
playbooks-ai: charts/playbooks-ai/**
playbooks-flux: charts/playbooks-flux/**
misc-playbooks: charts/misc-playbooks/**
mssql: charts/mssql/**
helm: charts/helm/**
# Job to build and test each of modified packages
build:
needs: changes
strategy:
fail-fast: false
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['package1', 'package2'] if both package folders contains changes
chart: ${{ fromJSON(needs.changes.outputs.charts) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: "${{ secrets.FLANKBOT }}"
- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.12.0
- name: Package Helm chart
run: |
cd charts/${{ matrix.chart }}
CURRENT_CHART_VERSION=$(cat Chart.yaml | yq '.version')
# Regex to match SemVer pattern with optional beta version
# This matches versions like `1.2.3`, `1.2.3-beta.1`, etc.
SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)(-beta\.([0-9]+))?$"
# Check if version matches the SemVer pattern
if [[ $CURRENT_CHART_VERSION =~ $SEMVER_REGEX ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
BETA="${BASH_REMATCH[5]}"
if [[ -n "$BETA" ]]; then
# If there's a beta version, increment it
NEW_BETA=$((BETA + 1))
NEW_CHART_VERSION="${MAJOR}.${MINOR}.${PATCH}-beta.${NEW_BETA}"
else
# If no beta version, bump the PATCH and start with beta.1
NEW_PATCH=$((PATCH + 1))
NEW_CHART_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}-beta.1"
fi
else
echo "Invalid semantic version format."
exit 1
fi
echo NEW_CHART_VERSION=$NEW_CHART_VERSION >> $GITHUB_ENV
yq -i e ".version |= \"$NEW_CHART_VERSION\"" Chart.yaml
helm package -d ../.. .
git config --global user.name 'flankbot'
git config --global user.email 'flankbot@users.noreply.github.com'
git add Chart.yaml
git pull --rebase origin main --autostash
git commit -m "[skip ci] bump chart ${{matrix.chart}} to $NEW_CHART_VERSION"
git push
- name: Clone charts repo
uses: actions/checkout@v3
with:
repository: "${{ github.repository_owner }}/charts"
path: chart-index
token: "${{ secrets.FLANKBOT }}"
- name: Update chart repo
run: |
cd chart-index
cp ../mission-control-*.tgz ./
helm repo index --merge index.yaml .
- name: Push changes to chart repo
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Release ${{ env.NEW_CHART_VERSION }} of mission-control-${{ matrix.chart }}"
branch: gh-pages
repository: ./chart-index