-
Notifications
You must be signed in to change notification settings - Fork 21
130 lines (107 loc) · 6.06 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
name: Release
env:
IMAGE_NAME: activemq-artemis-operator
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install prerequisites
run: >
sudo apt-get update &&
sudo apt-get install pass
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.11'
- name: Checkout the repo
uses: actions/checkout@v4
with:
token: ${{ secrets.BOT_TOKEN }}
- name: Create release tag
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
git fetch --tags --force
HEAD_COMMIT="$(git rev-parse HEAD)"
RELEASE_TAG="$(grep -m 1 -oP '(?<=Version = ")[^"]+' version/version.go)"
RELEASE_TAG_COMMIT="$(git rev-list -n 1 ${RELEASE_TAG} || true)"
if [ "$RELEASE_TAG_COMMIT" != "$HEAD_COMMIT" ]; then
git config user.name 'arkmq-bot'
git config user.email '[email protected]'
git tag -a ${RELEASE_TAG} -m ${RELEASE_TAG} --force
git push origin $RELEASE_TAG --force
fi
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Check doc.crds.dev
run: for i in {1..30}; do curl "https://doc.crds.dev/github.com/${{ github.repository }}@${{ github.ref_name }}" | grep 'ActiveMQArtemis' && break; sleep 1; done
- name: Checkout arkmq-org.github.io
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/arkmq-org.github.io
path: arkmq-org.github.io
token: ${{ secrets.BOT_TOKEN }}
- name: Build the docs
run: >
rm -rf arkmq-org.github.io/content/en/docs &&
cp -r docs arkmq-org.github.io/content/en &&
cd arkmq-org.github.io &&
npm install && npm run build
- name: Push the docs
run: >
cd arkmq-org.github.io &&
git config user.name 'Arkmq Bot' &&
git config user.email '[email protected]' &&
git add --all && git commit --all --allow-empty --message 'Update docs to ${{ github.ref_name }}' && git push
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build the image
run: |
podman build --build-arg TARGETOS=linux --build-arg TARGETARCH=amd64 --no-cache --platform linux/amd64 --manifest $IMAGE_NAME:latest .
podman build --build-arg TARGETOS=linux --build-arg TARGETARCH=arm64 --no-cache --platform linux/arm64 --manifest $IMAGE_NAME:latest .
- name: Push the image
run: |
IMAGE_TAG="$(git describe --exact-match --tags | sed 's/v//')"
podman login --username=${{ secrets.QUAY_USERNAME }} --password=${{ secrets.QUAY_PASSWORD }} quay.io
podman manifest push $IMAGE_NAME:latest docker://quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME:latest
podman manifest push $IMAGE_NAME:latest docker://quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME:$IMAGE_TAG
- name: Build the bundle image
run: export BUNDLE_IMG=$IMAGE_NAME-bundle:latest && make bundle-build
- name: Push the bundle image
run: >
RELEASE_TAG="$(git describe --exact-match --tags)" && IMAGE_TAG=${RELEASE_TAG#v} &&
docker login --username=${{ secrets.QUAY_USERNAME }} --password=${{ secrets.QUAY_PASSWORD }} quay.io &&
docker tag $IMAGE_NAME-bundle:latest quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME-bundle:$IMAGE_TAG &&
docker push quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME-bundle:$IMAGE_TAG &&
docker tag $IMAGE_NAME-bundle:latest quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME-bundle:latest &&
docker push quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME-bundle:latest
- name: Create GitHub release
run: |
RELEASE_TAG="$(git describe --exact-match --tags)"
RELEASE_ID=$(curl -v -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${RELEASE_TAG}" | jq -r '.id')
if [ -n "$RELEASE_ID" ]; then
curl -v -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}"
fi
RELEASE_ID=$(curl -v -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/releases" \
-d "$(jq -c -n --arg tag_name "${RELEASE_TAG}" '{"tag_name":$tag_name,"generate_release_notes":true}')" | jq -r '.id')
RELEASE_PACKAGE="activemq-artemis-operator-${RELEASE_TAG}"
INSTALL_YAML="activemq-artemis-operator.yaml"
rm -rf /tmp/${RELEASE_PACKAGE}
mkdir -p /tmp/${RELEASE_PACKAGE}
cp -r deploy/* /tmp/${RELEASE_PACKAGE}
cp -r config/crs /tmp/${RELEASE_PACKAGE}
cp -r examples /tmp/${RELEASE_PACKAGE}
cd /tmp/${RELEASE_PACKAGE}
zip -r /tmp/${RELEASE_PACKAGE}.zip .
curl -v -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" -H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${RELEASE_PACKAGE}.zip" --data-binary "@/tmp/${RELEASE_PACKAGE}.zip"
curl -v -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" -H "Content-Type: text/plain" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${INSTALL_YAML}" --data-binary "@/tmp/${RELEASE_PACKAGE}/${INSTALL_YAML}"