-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (122 loc) · 6.2 KB
/
prep-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
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag'
required: true
default: '1.2.0'
prep_internal_release:
# Need to distinguish between internal and external releases
# Internal release: Will use default internal location for created images (ghcr.io) and will tag and push operator candidate there
# External release: Assumes tagged image operator already pushed to docker.io/solace.
# The purpose of running this script is to update final release tags and getting ready for PR to Operator Hub
type: boolean
description: 'Internal release (Check to prep an internal release including image push. Uncheck to prep an external release)'
required: true
default: true
jobs:
build_web:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.7
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup tools
run: |
# Operator SDK
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.27.0
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
- name: Update code
run: |
make generate manifests
make fmt
- name: Get params ref generator and update params ref doc
run: |
# crdoc
pushd /tmp
curl -s https://api.github.com/repos/fybrik/crdoc/releases/latest | grep -wo "https://.*crdoc.*Linux_x86.*gz" | wget -i -
tar -xvf crdoc*.gz
popd
/tmp/crdoc --resources config/crd/bases/pubsubplus.solace.com_pubsubpluseventbrokers.yaml --output docs/EventBrokerOperatorParametersReference.md --template config/crdoc/markdown.tmpl
- name: Generate Third Party License
run: |
make generate-license
- name: Build bundle - will use the generated license file
run: |
export VERSION='${{ github.event.inputs.release_tag }}'
if [ "${{ github.event.inputs.prep_internal_release }}" == "true" ] ; then
echo Internal release
echo "CONTROLLER_CONTAINER_REPO=ghcr.io/solacedev" >> $GITHUB_ENV
make docker-build docker-push
else
echo External release
export CONTROLLER_CONTAINER_REPO=docker.io/solace
echo "CONTROLLER_CONTAINER_REPO=$CONTROLLER_CONTAINER_REPO" >> $GITHUB_ENV
make docker-build
# skip docker-push
fi
make create-deploy-yaml
make bundle
- name: Prep for testing - create K8s Kind Cluster
uses: helm/[email protected]
- name: Test operator image using preflight tool
run: |
pushd /tmp
curl -s https://api.github.com/repos/redhat-openshift-ecosystem/openshift-preflight/releases/latest | grep -wo "https://.*preflight-linux-amd64" | wget -i -
chmod +x preflight-linux-amd64
popd
export CONTAINER_TO_TEST="$CONTROLLER_CONTAINER_REPO/pubsubplus-eventbroker-operator:v${{ github.event.inputs.release_tag }}"
/tmp/preflight-linux-amd64 check container $CONTAINER_TO_TEST --docker-config ~/.docker/config.json | grep "Preflight result: PASSED" || echo
- name: Test operator bundle - validate and scorecard
run: |
operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
operator-sdk bundle validate ./bundle --select-optional name=good-practices
operator-sdk scorecard ./bundle --kubeconfig ~/.kube/config
- name: Build and publish Operator bundle and catalog
run: |
export VERSION='${{ github.event.inputs.release_tag }}'
make bundle-build bundle-push
make catalog-build catalog-push
# tag each as latest
PUSHED_IMAGES=`docker images | grep $VERSION`
BUNDLE=`echo "$PUSHED_IMAGES" | grep bundle` ; echo "$BUNDLE" # Format: Imagepath Tag Sha
docker tag `echo $BUNDLE | awk '{print $3}'` `echo $BUNDLE | awk '{print $1}'`:latest
docker push `echo $BUNDLE | awk '{print $1}'`:latest
CATALOG=`echo "$PUSHED_IMAGES" | grep catalog` ; echo "$CATALOG" # Format: Imagepath Tag Sha
docker tag `echo $CATALOG | awk '{print $3}'` `echo $CATALOG | awk '{print $1}'`:latest
docker push `echo $CATALOG | awk '{print $1}'`:latest
- name: Run Whitesource Action
uses: SolaceDev/[email protected]
with:
wssURL: https://saas.whitesourcesoftware.com/agent
apiKey: ${{ secrets.WSS_API_KEY }}
productName: 'pubsubplus-kubernetes-operator'
projectName: 'pubsubplus-kubernetes-operator'
configFile: 'ci/whitesource/whitesource-agent.config'
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
committer_name: GitHub Actions
committer_email: [email protected]
message: 'Prepared deploy yaml, bundle with latest relase info and updated params doc and licenses [skip ci]'
add: 'deploy/*.yaml bundle/manifests/*.yaml docs/EventBrokerOperatorParametersReference.md THIRD-PARTY-LICENSES.md'
new_branch: 'ReleaseCandidate-${{ github.event.inputs.release_tag }}'
- name: Create pull request
run: |
CURRENT_BRANCH=${GITHUB_REF##*/}
gh pr create -B ${CURRENT_BRANCH} -H 'ReleaseCandidate-${{ github.event.inputs.release_tag }}' --title "Merge release prep updates into ${CURRENT_BRANCH}" --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}