-
Notifications
You must be signed in to change notification settings - Fork 29
225 lines (199 loc) · 9.73 KB
/
release.yaml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Release
on:
workflow_dispatch:
permissions:
contents: write
packages: write
env:
ContainerRegistry: "ghcr.io"
ContainerRegistryRepo: "ghcr.io/eclipse-symphony"
BOT_USER_NAME: eclipse-symphoy-bot
BOT_EMAIL_ID: symphony-bot@eclipse.org
IMAGE_NAME: ${{ github.repository }}
# Two users are used in this pipeline
# BOT_USER_NAME (eclipse-symphoy-bot) / secrets.BOT_GITHUB_TOKEN is used to checkout/commit/push the changes to the repository
# github.repository_owner / secrets.GITHUB_TOKEN is used to login to the docker registry and helm registry and to create the release
jobs:
build:
if: github.repository == 'eclipse-symphony/symphony' && github.event_name != 'pull_request' && (github.actor == 'chgennar' || github.actor == 'juancooldude' || github.actor == 'Haishi2016' || github.actor == 'nonsocode' || github.actor == 'msftcoderdjw' || github.actor == 'TonyXiaofeng' || github.actor == 'iwangjintian')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Print branch name
run: echo ${{ steps.extract_branch.outputs.branch }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y make gcc
sudo snap install yq
- name: Install Helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.ContainerRegistry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Helm Registry
run: helm registry login ${{ env.ContainerRegistry }} -u ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.4 # Replace with your desired Go version
- name: Install Kubebuilder
run: |
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/$(go env GOOS)/$(go env GOARCH)
chmod +x kubebuilder
sudo mv kubebuilder /usr/local/bin/
- name: Install Mage
run: |
cd ..
git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go
cd ..
- name: Increment Version
id: increment_version
run: |
version=$(cat .github/version/versions.txt)
IFS='.' read -ra VERSION_PARTS <<< "$version"
VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1))
new_version="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
echo $new_version > .github/version/versions.txt
echo "version=$new_version" >> $GITHUB_OUTPUT
- name: Build Symphony Api
run: |
cd api
mage dockerBuildAPIMultiPlatform
mage dockerBuildTargetAgentMultiPlatform
mage dockerBuildPollAgentMultiPlatform
- name: Build Symphony k8s
run: |
cd k8s
mage dockerBuildK8sMultiPlatform
- name: Replace version in cli/cmd/up.go
run: |
version=$(cat .github/version/versions.txt)
sed -i "s/const SymphonyAPIVersion = .*/const SymphonyAPIVersion = \"$version\"/" cli/cmd/up.go
- name: Build maestro
run: |
cd cli
mage generatePackages /home/runner/maestro
cd ..
- name: Replace version in packages/helm/values.yaml
run: |
version=$(cat .github/version/versions.txt)
yq eval -i ".version = \"$version\"" packages/helm/symphony/Chart.yaml
yq eval -i ".appVersion = \"$version\"" packages/helm/symphony/Chart.yaml
yq eval -i ".version = \"$version\"" packages/helm/symphony-poll-agent/Chart.yaml
yq eval -i ".appVersion = \"$version\"" packages/helm/symphony-poll-agent/Chart.yaml
sed -i "s/{VERSION}/${{ steps.increment_version.outputs.version }}/g" packages/helm/symphony/values.yaml
sed -i "s/{VERSION}/${{ steps.increment_version.outputs.version }}/g" packages/helm/symphony-poll-agent/values.yaml
- name: Build Helm
run: |
cd k8s
mage helmTemplate
cd ../packages/helm
helm package symphony
helm package symphony-poll-agent
- name: Push symphony api images
run: |
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-api:latest ${{ env.ContainerRegistryRepo }}/symphony-api-multi:latest
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-api:${{ steps.increment_version.outputs.version }} ${{ env.ContainerRegistryRepo }}/symphony-api-multi:latest
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-target-agent:latest ${{ env.ContainerRegistryRepo }}/symphony-target-agent-multi:latest
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-target-agent:${{ steps.increment_version.outputs.version }} ${{ env.ContainerRegistryRepo }}/symphony-target-agent-multi:latest
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-poll-agent:latest ${{ env.ContainerRegistryRepo }}/symphony-poll-agent-multi:latest
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-poll-agent:${{ steps.increment_version.outputs.version }} ${{ env.ContainerRegistryRepo }}/symphony-poll-agent-multi:latest
- name: Push symphony k8s images
run: |
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-k8s:latest ${{ env.ContainerRegistryRepo }}/symphony-k8s-multi:latest
docker buildx imagetools create -t ${{ env.ContainerRegistryRepo }}/symphony-k8s:${{ steps.increment_version.outputs.version }} ${{ env.ContainerRegistryRepo }}/symphony-k8s-multi:latest
- name: Push symphony helm package
run: |
cd packages/helm
helm push symphony-${{ steps.increment_version.outputs.version }}.tgz oci://${{ env.ContainerRegistryRepo }}/helm
helm push symphony-poll-agent-${{ steps.increment_version.outputs.version }}.tgz oci://${{ env.ContainerRegistryRepo }}/helm
- name: Commit changes
run: |
git config --local user.name ${{ env.BOT_USER_NAME }}
git config --local user.email ${{ env.BOT_EMAIL_ID }}
git add .github/version/versions.txt
git add packages/helm/symphony/Chart.yaml
git add cli/cmd/up.go
git commit -m "Bump version to ${{ steps.increment_version.outputs.version }}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.BOT_GITHUB_TOKEN }}
branch: ${{ steps.extract_branch.outputs.branch }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.increment_version.outputs.version }}
release_name: Release ${{ steps.increment_version.outputs.version }}
draft: false
prerelease: false
- name: Upload windows mastro packages
id: upload_mastro_windows_package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /home/runner/maestro/maestro_windows_amd64.zip
asset_name: maestro_windows_amd64.zip
asset_content_type: application/gzip
- name: Upload linux mastro packages
id: upload_mastro_linux_package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /home/runner/maestro/maestro_linux_amd64.tar.gz
asset_name: maestro_linux_amd64.tar.gz
asset_content_type: application/gzip
- name: Upload linux mastro ARM64 packages
id: upload_mastro_linux_arm64_package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /home/runner/maestro/maestro_linux_arm64.tar.gz
asset_name: maestro_linux_arm64.tar.gz
asset_content_type: application/gzip
- name: Upload linux mastro ARM7 packages
id: upload_mastro_linux_arm_package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /home/runner/maestro/maestro_linux_arm.tar.gz
asset_name: maestro_linux_arm.tar.gz
asset_content_type: application/gzip
- name: Upload mac mastro packages
id: upload_mastro_mac_package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /home/runner/maestro/maestro_darwin_amd64.tar.gz
asset_name: maestro_darwin_amd64.tar.gz
asset_content_type: application/gzip