-
Notifications
You must be signed in to change notification settings - Fork 77
156 lines (140 loc) · 5.86 KB
/
semver.yml
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
#
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# 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
#
# https://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: Run semver
on:
push:
branches:
- main
jobs:
dump-contexts-to-log:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/dump-context
semver-auto:
name: Run semver-auto
runs-on: ubuntu-latest
container:
image: ghcr.io/vdaas/vald/vald-ci-container:nightly
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.DISPATCH_TOKEN }}
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Get latest gitwerk
run: |
curl -fsSLO \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
https://github.com/rinx/gitwerk/releases/latest/download/gitwerk-linux-amd64.zip
unzip gitwerk-linux-amd64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run gitwerk semver-auto
id: semver
run: |
GITWERK_RESULT=`./gitwerk --stdin sv << EOF
(defn sv []
(let [repo (git/repo ".")
message (-> repo
(git/latest-log)
:full-message)
tag (or (-> repo
(git/tags)
(semver/latest-tag))
(semver/default-version-str))
new-tag (semver/contextual-semver message tag)]
(if (not (= tag new-tag))
new-tag
"not-updated")))
EOF`
if [ "${GITWERK_RESULT}" = "not-updated" ]; then
echo "version not updated"
exit 0
fi
echo "version updated: ${GITWERK_RESULT}"
git checkout main
LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1`
PR_NUM=`echo "$LAST_COMMIT_MESSAGE" | grep -o "#[[:digit:]]\+" | sed -e 's/#//' | head -1`
PREVIOUS_VERSION=`cat versions/VALD_VERSION`
echo "${GITWERK_RESULT}" > versions/VALD_VERSION
sed -i -e "s/^version: .*$/version: ${GITWERK_RESULT}/" charts/vald/Chart.yaml
sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${GITWERK_RESULT}/" charts/vald/values.yaml
sed -i -e "s/^version: .*$/version: ${GITWERK_RESULT}/" charts/vald-helm-operator/Chart.yaml
sed -i -r "s/^(\s*)tag\s*:\s*v[0-9]+\.[0-9]+\.[0-9]+\s*$/\1tag: ${GITWERK_RESULT}/" charts/vald-helm-operator/values.yaml
make helm/schema/vald
make helm/schema/vald-helm-operator
make helm/schema/crd/vald
make helm/schema/crd/vald-helm-operator
make k8s/manifest/update
make k8s/manifest/helm-operator/update
make helm/docs/vald
make helm/docs/vald-helm-operator
BODY=""
if [ ! -z "${PR_NUM}" ]; then
BODY=`curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUM}" | jq -r '.body'`
fi
if [ -z "$BODY" ]; then
BODY=`git log --pretty=format:'- %s' ${PREVIOUS_VERSION}..main | grep "#[[:digit:]]\+" | sed -e "s/\[\(patch\|minor\|major\)\] *//g" | sed -e "s%#\([[:digit:]]\+\)%[&](https://github.com/vdaas/vald/pull/\1)%"`
fi
CHANGELOG=`make changelog/next/print BODY="$BODY"`
make changelog/update BODY="$BODY"
make format
git add \
CHANGELOG.md \
charts/vald-helm-operator/Chart.yaml \
charts/vald-helm-operator/README.md \
charts/vald-helm-operator/values.schema.json \
charts/vald-helm-operator/values.yaml \
charts/vald/Chart.yaml \
charts/vald/README.md \
charts/vald/values.schema.json \
charts/vald/values.yaml \
k8s \
versions/VALD_VERSION
git commit -S --signoff -m ":bookmark: :robot: Release ${GITWERK_RESULT}"
git tag ${GITWERK_RESULT}
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push origin main
git push origin ${GITWERK_RESULT}
echo "RELEASE=true" >> $GITHUB_OUTPUT
echo "VERSION=${GITWERK_RESULT}" >> $GITHUB_OUTPUT
env:
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
- name: Create release
if: steps.semver.outputs.RELEASE == 'true'
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
with:
tag_name: ${{ steps.semver.outputs.VERSION }}
release_name: Release ${{ steps.semver.outputs.VERSION }}
body: |
See [CHANGELOG.md](https://github.com/vdaas/vald/blob/${{ steps.semver.outputs.VERSION }}/CHANGELOG.md) for details.
draft: false
prerelease: false
- name: Add the version to goproxy
run: |
curl "https://proxy.golang.org/github.com/vdaas/vald/@v/${{ steps.semver.outputs.VERSION }}.info"