-
Notifications
You must be signed in to change notification settings - Fork 54
141 lines (122 loc) · 5.14 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
name: Release DevWorkspace Operator
on:
workflow_dispatch:
inputs:
version:
description: 'version in format v0.y.z'
required: true
prerelease:
description: If true, prerelease will be done, otherwise release
required: true
forceRecreateTags:
description: If true, tags will be recreated. Use with caution
required: false
default: 'false'
dryrun:
description: If true, dry-run will be executed - no result are pushed
required: false
default: 'false'
jobs:
release:
env:
OPERATOR_SDK_VERSION: v1.8.0
OPM_VERSION: v1.19.5
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.x
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.20.10
- name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 #v2.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 #v2.10.0
- name: Clone source code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0
- name: Check existing tags
run: |
set +e
RECREATE_TAGS=${{ github.event.inputs.forceRecreateTags }}
VERSION=${{ github.event.inputs.version }}
EXISTING_TAG=$(git ls-remote --exit-code origin refs/tags/${VERSION})
if [[ -n ${EXISTING_TAG} ]]; then
if [[ ${RECREATE_TAGS} == "true" ]]; then
echo "[INFO] Removing tag for ${VERSION} version. New tag will be recreated during release."
git push origin :$VERSION
else
echo "[ERROR] Cannot proceed with release - tag ${EXISTING_TAG} already exists."
exit 1
fi
else
echo "[INFO] No existing tags detected for $VERSION"
fi
- name: Cache Operator SDK ${{ env.OPERATOR_SDK_VERSION }}
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.0
id: cache-operator-sdk
with:
path: ~/cache
key: operator-sdk-${{ env.OPERATOR_SDK_VERSION }}
- name: Download Operator SDK ${{ env.OPERATOR_SDK_VERSION }}
if: steps.cache-operator-sdk.outputs.cache-hit != 'true'
run: |
mkdir -p ~/cache
wget https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64 -O ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} > /dev/null -O ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} > /dev/null
chmod +x ~/cache/operator-sdk-${OPERATOR_SDK_VERSION}
- name: Install Operator SDK ${{ env.OPERATOR_SDK_VERSION }}
run: |
mkdir -p ~/bin
cp ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} ~/bin/operator-sdk
echo "$HOME/bin" >> $GITHUB_PATH
- name: Cache OPM ${{ env.OPM_VERSION }}
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.0
id: cache-opm
with:
path: ~/cache
key: opm-${{ env.OPM_VERSION }}
- name: Download OPM ${{ env.OPM_VERSION }}
if: steps.cache-opm.outputs.cache-hit != 'true'
run: |
mkdir -p ~/cache
wget https://github.com/operator-framework/operator-registry/releases/download/${OPM_VERSION}/linux-amd64-opm -O ~/cache/opm${OPM_VERSION} > /dev/null
#${OPM_VERSION} is used in binary name to prevent caching after upgrading
chmod +x ~/cache/opm${OPM_VERSION}
- name: Install OPM ${{ env.OPM_VERSION }}
run: |
mkdir -p ~/bin
cp ~/cache/opm${OPM_VERSION} ~/bin/opm
echo "$HOME/bin" >> $GITHUB_PATH
- name: Login to quay.io
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc #v2.2.0
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Set up yq
uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0
with:
python-version: 3.6
- name: Setup yq
run: |
python -m pip install --upgrade pip
pip install yq
cd ${GITHUB_WORKSPACE}
- name: Release
run: |
# Need to grab goimports otherwise formatting after this step will fail
# PR checks.
go install golang.org/x/tools/cmd/[email protected]
git config --global user.name "David Kwon"
git config --global user.email "[email protected]"
export GITHUB_TOKEN=${{ secrets.CHE_INCUBATOR_BOT_GITHUB_TOKEN }}
RELEASE_COMMAND="./make-release.sh --version ${{ github.event.inputs.version }}"
if [[ "${{ github.event.inputs.prerelease }}" == "true" ]]; then
RELEASE_COMMAND="$RELEASE_COMMAND --prerelease"
else
RELEASE_COMMAND="$RELEASE_COMMAND --release"
fi
if [[ "${{ github.event.inputs.dry-run }}" == "true" ]]; then
RELEASE_COMMAND="$RELEASE_COMMAND --dry-run"
fi
$RELEASE_COMMAND