-
Notifications
You must be signed in to change notification settings - Fork 2
81 lines (68 loc) · 2.51 KB
/
trigger-push.yaml
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
name: Tag on Renovate Commits (Canary)
on:
push:
branches:
- 'main'
jobs:
find-tags-to-release:
runs-on: ubuntu-latest
permissions:
contents: write # for creating tags
outputs:
release-tags: ${{ steps.list-release-tags.outputs.release-tags }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"
- name: Get list of changed namespaces
id: list-changed-namespaces
uses: tj-actions/changed-files@v35.9.2
with:
files: |
./*/helmfile.yaml
./*/values/**
dir_names: "true"
dir_names_max_depth: "1"
- name: List and create tags
id: list-release-tags
shell: bash
run: |
set -e
tags=()
for namespace_name in ${{ steps.list-changed-namespaces.outputs.all_modified_files }}; do
set +e
latest_version="$(git -c 'versionsort.suffix=-' tag --sort 'version:refname' --list "$namespace_name-*" | grep -E '.*-v?[[:digit:]]+.[[:digit:]]+.[[:digit:]]+$' | tail -n1)"
set -e
if [ -z "$latest_version" ]; then
latest_version="${namespace_name}-v0.0.0"
fi
next_patch="$(echo "$latest_version" | sed -E 's/(.*-)?v?([[:digit:]]+).([[:digit:]]+).([[:digit:]]+)/echo v\2.\3.$((\4 + 1))/e')"
set +e
last_pre_tag="$(git -c 'versionsort.suffix=-' tag --sort 'version:refname' --list "$namespace_name-$next_patch-*" | tail -n1)"
set -e
if [ -z "$last_pre_tag" ]; then
index=1
else
index=$(echo "$last_pre_tag" | sed -E 's/(.*-)?v?[[:digit:]]+.[[:digit:]]+.[[:digit:]]+-canary.([[:digit:]]+)(#.*)?/echo $((\2 + 1))/e')
fi
next_tag="$namespace_name-$next_patch-canary.$index"
tags+=("$next_tag")
git tag -a "$next_tag" -m "Release $next_tag"
done
git push --tags
echo "release-tags<<EOF" >> $GITHUB_OUTPUT
echo "$(jq -Rc '. / " "' <<< ${tags[*]})" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
call-update-tags:
uses: ./.github/workflows/update-tags.yaml
needs:
- find-tags-to-release
permissions:
contents: write
secrets:
LABELS_TOKEN: "${{ secrets.LABELS_TOKEN }}"