-
Notifications
You must be signed in to change notification settings - Fork 16
156 lines (133 loc) · 5.47 KB
/
release.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
---
name: Release
on:
push:
branches:
- test-release-ci
permissions:
contents: write
packages: write
checks: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
#VERSION: ${{ github.event.inputs.version }}
VERSION: 0.11.0
#RELEASE_TYPE: ${{ github.event.inputs.releaseType }}
RELEASE_TYPE: minor
# version in format "X.Y" which is going to be updated with each patch release
FLOATING_TAG: ''
# branch name in format "release-X.Y"
BRANCH_NAME: ''
# GitHub tag name to use for the RC/Release
GH_TAG: ''
# Shows if this workflow is triggered for RC or Release
IS_RC: 0
ARCH: ''
OS: ''
steps:
- name: Validate input
run: |
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc[1-9][0-9]*)?$ ]]; then
echo "Wrong version format provided, please use "X.Y.Z-rcN" format for an RC or "X.Y.Z" format for a release"
exit 1
fi
- name: Set environment variables
run: |
floating_tag=${VERSION%.*}
echo "FLOATING_TAG=$floating_tag" >> $GITHUB_ENV
echo "BRANCH_NAME=release-$floating_tag" >> $GITHUB_ENV
echo "GH_TAG=v$VERSION" >> $GITHUB_ENV
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "IS_RC=1" >> $GITHUB_ENV
fi
echo "ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')" >> $GITHUB_ENV
echo "OS=$(uname | awk '{print tolower($0)}')" >> $GITHUB_ENV
- name: Catalog - checkout
uses: actions/checkout@v4
with:
repository: percona/everest-catalog
path: everest-catalog
token: ${{ secrets.ROBOT_TOKEN }}
- name: Catalog - create release branch
run: |
cd everest-catalog
# Check if the branch already exists
git fetch
check_branch=$(git ls-remote --heads origin ${BRANCH_NAME})
if [[ -z ${check_branch} ]]; then
git checkout -b $BRANCH_NAME
git push origin $BRANCH_NAME
fi
git checkout $BRANCH_NAME
# if the tag doesn't exist yet, create it
if git tag --list | grep -q "^$GH_TAG$"; then
echo "The tag is already present in github. Please create a different RC/Release"
exit 1
fi
- name: Catalog - update veneer file
run: |
cd everest-catalog
# configure userdata for commits
git config --global user.email "[email protected]"
git config --global user.name "Everest RC CI triggered by ${{ github.actor }}"
CURRENT_STABLE_VERSION=$(yq 'select(.name == "stable-v0").entries[-1].name' veneer/everest-operator.yaml | sed 's/^everest-operator.v//')
CURRENT_FAST_VERSION=$(yq 'select(.name == "fast-v0").entries[-2].name' veneer/everest-operator.yaml | sed 's/^everest-operator.v//')
if [[ -z "$CURRENT_STABLE_VERSION" ]]; then
echo "CURRENT_STABLE_VERSION is required"
exit 1
fi
if [[ -z "$CURRENT_FAST_VERSION" ]]; then
echo "CURRENT_FAST_VERSION is required"
exit 1
fi
echo "CURRENT_STABLE_VERSION=$CURRENT_STABLE_VERSION"
echo "CURRENT_FAST_VERSION=$CURRENT_FAST_VERSION"
cp veneer/everest-operator.yaml veneer/everest-operator-original.yaml
echo "---- 0"
cat veneer/everest-operator-original.yaml
if [[ $env.IS_RC ]]; then
go run ./tools/ \
--veneer-file veneer/everest-operator-original.yaml \
--version-type ${{ env.RELEASE_TYPE }} \
--channel fast-v0 \
--new-version ${{ env.VERSION }} \
--current-version "$CURRENT_FAST_VERSION" \
\
>| veneer/everest-operator.yaml
else
go run ./tools/ \
--veneer-file veneer/everest-operator-original.yaml \
--version-type ${{ env.RELEASE_TYPE }} \
--channel stable-v0 \
--new-version ${{ env.VERSION }} \
--current-version "$CURRENT_STABLE_VERSION" \
\
>| veneer/everest-operator.yaml
echo "---- 1"
cat veneer/everest-operator.yaml
go run ./tools/ \
--veneer-file veneer/everest-operator-original.yaml \
--version-type ${{ env.RELEASE_TYPE }} \
--channel fast-v0 \
--new-version ${{ env.VERSION }} \
--current-version "$CURRENT_FAST_VERSION" \
\
>| veneer/everest-operator.yaml
echo "---- 2"
cat veneer/everest-operator.yaml
fi
rm -f veneer/everest-operator-original.yaml
curl -Lo /tmp/opm https://github.com/operator-framework/operator-registry/releases/latest/download/${OS}-${ARCH}-opm
chmod +x /tmp/opm
/tmp/opm alpha render-template basic -o yaml < veneer/everest-operator.yaml > catalog/everest-operator/catalog.yaml
# Check if veneer has the new version listed
if ! grep -q "$VERSION$" catalog/everest-operator/catalog.yaml; then
echo "catalog/everest-operator/catalog.yaml does not include the version $VERSION"
exit 1
fi
git commit -am "CI: add version ${{ env.VERSION }}"
git push origin $BRANCH_NAME