Skip to content

Commit 8001f81

Browse files
committed
CLOUDP-226369: Allow backport releases
Signed-off-by: jose.vazquez <[email protected]>
1 parent 2fcc060 commit 8001f81

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

.github/actions/releaser/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
dryrun:
1919
description: "not actually release, but check what would be done"
2020
required: false
21+
mark_latest:
22+
description: "mark released charts as latest"
23+
required: false
24+
default: "true"
2125

2226
runs:
2327
using: composite
@@ -28,6 +32,7 @@ runs:
2832
export CHART_DIR="${{ inputs.charts_dir }}"
2933
export CHARTS_REPO_URL="${{ inputs.charts_repo_url }}"
3034
export DRYRUN="${{ inputs.dryrun }}"
35+
export MARK_LATEST="${{ inputs.mark_latest }}"
3136
3237
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
3338
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")

.github/actions/releaser/cr.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ set -o errexit
88
set -o nounset
99
set -o pipefail
1010

11+
set -x
12+
13+
mark_latest=${MARK_LATEST:-true}
14+
1115
main() {
1216
local version=${VERSION:-v1.2.1}
1317
local charts_dir=${CHART_DIR:-charts}
@@ -58,7 +62,7 @@ release_charts_inside_folders() {
5862
echo "released result: \"${chart_was_released}\""
5963

6064
# if chart is not released or folder has change, then remember as changed_charts
61-
if [ -z "${chart_was_released}" ] || has_changed "$folder"; then
65+
if [ "${chart_was_released}" == "Not found" ] || has_changed "$folder"; then
6266
changed_charts+=("$folder")
6367
fi
6468
done
@@ -95,16 +99,20 @@ check_charts_released() {
9599
echo "Checking if \"$charts_dir/$folder\" has been released to the repo"
96100
chart_was_released=$(chart_released "${chart_name}" "${chart_version}")
97101

98-
echo "released result: \"${chart_was_released}\""
102+
echo "Has been released result: \"${chart_was_released}\""
99103

100-
if [ -z "${chart_was_released}" ]; then
104+
if [ "${chart_was_released}" == "Not found" ]; then
101105
unreleased_charts+=("$chart_name")
102106
fi
103107
done
104108

105109
if [[ -n "${unreleased_charts[*]}" ]]; then
106-
echo "FAIL: found unreleased charts:" "${unreleased_charts[@]}"
107-
exit 1
110+
if [ "${DRYRUN}" == "true" ]; then
111+
echo "DRYRUN: would have not seen released charts for" "${unreleased_charts[@]}"
112+
else
113+
echo "FAIL: found unreleased charts:" "${unreleased_charts[@]}"
114+
exit 1
115+
fi
108116
else
109117
echo "PASS: all latest helm charts released for" "${folders[@]}"
110118
fi
@@ -219,7 +227,7 @@ package_charts() {
219227
}
220228

221229
release_charts() {
222-
local args=(-o "$owner" -r "$repo" -c "$(git rev-parse HEAD)")
230+
local args=(-o "$owner" -r "$repo" -c "$(git rev-parse HEAD)" --make-release-latest "${mark_latest}")
223231

224232
echo 'Releasing charts...'
225233
cr upload "${args[@]}"

.github/workflows/main.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,33 @@ on:
1414
default: ""
1515
required: false
1616
dryrun:
17-
description: "not actually release, but check what would be done"
17+
description: "dry-run"
1818
type: boolean
1919
default: true
2020
required: false
21+
backport-branch:
22+
description: "Branch or leave empty for current CI branch"
23+
type: string
24+
default: ""
25+
required: true
2126

2227
jobs:
2328
build:
2429
runs-on: ubuntu-latest
30+
env:
31+
BACKPORT_BRANCH: ${{ github.event.inputs.backport-branch || '' }}
32+
BACKPORT_DIR: 'backport'
2533
steps:
2634
- name: Checkout
2735
uses: actions/checkout@v4
2836

37+
- name: Checkout Backport branch
38+
uses: actions/checkout@v4
39+
if: github.event.inputs.backport-branch != ''
40+
with:
41+
ref: ${{ env.BACKPORT_BRANCH }}
42+
path: ${{ env.BACKPORT_DIR }}
43+
2944
- name: Configure Git
3045
run: |
3146
git config user.name "$GITHUB_ACTOR"
@@ -64,7 +79,11 @@ jobs:
6479
uses: ./.github/actions/releaser
6580
env:
6681
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
82+
CHARTS_DIR: ${{ github.event.inputs.backport-branch == '' && 'charts' || format('{0}/charts', env.BACKPORT_DIR) }}
83+
MARK_LATEST: ${{ github.event.inputs.backport-branch == '' && 'true' || 'false' }}
6784
with:
6885
charts_repo_url: https://mongodb.github.io/helm-charts
6986
target: ${{ github.event.inputs.target }}
7087
dryrun: ${{ github.event.inputs.dryrun }}
88+
charts_dir: ${{ env.CHARTS_DIR }}
89+
mark_latest: ${{ env.MARK_LATEST }}

0 commit comments

Comments
 (0)