-
Notifications
You must be signed in to change notification settings - Fork 34
295 lines (274 loc) · 9.49 KB
/
ci.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
name: CI
on:
push:
branches:
- develop
- release*
tags: [v*]
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
pull_request:
# Sequence of patterns matched against refs/heads
branches:
- develop
- release*
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
env:
PROJECT: 'focal-freedom-236620'
IMAGE_NAME: 'agent'
IOFOGCTL_VERSION: '3.0.8'
CONTROLLER_IMAGE: 'iofog/controller:latest'
jobs:
build:
runs-on: ubuntu-20.04
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
name: Build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# cache: 'gradle'
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.4
arguments: build
Integration:
runs-on: ubuntu-20.04
name: Integration
needs: Build
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
steps:
- uses: actions/checkout@v3
- run: sudo apt-get install jq
- run: |
curl https://packagecloud.io/install/repositories/iofog/iofogctl/script.deb.sh | sudo bash
sudo apt-get install iofogctl=${{ env.IOFOGCTL_VERSION }}
- name: 'Install bats'
run: |
sudo apt-get update -y
sudo apt-get install -y bats
- name: 'Deploy local ecn'
shell: bash
run: |
sed -i "s|CONTROLLER_IMAGE=.*|CONTROLLER_IMAGE=\"${{ env.CONTROLLER_IMAGE }}\"|g" test/resources/env.sh
sudo bash test/deploy_ecn.bash deployControlPlane
- name: 'Run integration test'
run: sudo bash test/run.bash
- name: 'Delete ECN'
if: always()
run: sudo bash test/deploy_ecn.bash deleteECN
Publish_dev:
runs-on: ubuntu-20.04
needs: [Build, Integration]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
outputs:
version: ${{ steps.step1.outputs.pkg_version }}
name: Publish_dev
steps:
- name: Test
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
echo "I am the tag"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.4
arguments: build
- name: Execute Gradle build
run: ./gradlew build
- name: 'ls jars'
run: |
cd packaging/iofog-agent/usr/bin
ls
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.0
- name: Set image tag
shell: bash
id: tags
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
VERSION=${{ github.ref_name }}
echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
else
VERSION=${{ steps.previoustag.outputs.tag }}
echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- name: Build and Push to GCR
if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
id: build_push_gcr
uses: RafikFarhad/push-to-gcr-github-action@v5-beta
with:
gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
registry: gcr.io
project_id: ${{ env.PROJECT }}
image_name: ${{ env.IMAGE_NAME }}
image_tag: latest, develop, ${{ steps.tags.outputs.VERSION }}
dockerfile: Dockerfile
- name: Login to Github Container Registry
if: ${{ github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and Push to ghcr
if: ${{ github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v3
id: build_push_ghcr
with:
file: Dockerfile
push: true
tags: |
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:latest
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:develop
- name: Set up Ruby 3.1.4
uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.4
- run: |
gem install --no-document fpm
fpm -h
- name: Install package_Cloud
run: |
gem install package_cloud
package_cloud -h
- name: get gradle version
shell: bash
id: version
run: echo "version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')" >> "${GITHUB_OUTPUT}"
- name: get package version
shell: bash
id: pkg_version
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
echo "version=${{ steps.version.outputs.version }}" >> "${GITHUB_OUTPUT}"
else
echo "version=${{ steps.version.outputs.version }}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- run: echo ${{ steps.version.outputs.version }}
- name: Create deb package
shell: bash
id: create_deb_package
run: |
cd packaging/iofog-agent
fpm -s dir -d 'openjdk-8-jdk | openjdk-11-jdk | openjdk-17-jdk' -d docker -t deb -n iofog-agent -v ${{ steps.pkg_version.outputs.version }} -a all --deb-no-default-config-files --after-install debian.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade debian.sh etc usr
echo "pkg created"
ls
- name: Create rpm package
shell: bash
id: create_rpm_package
run: |
cd packaging/iofog-agent
fpm -s dir --depends 'java-17-openjdk' -d docker-ce -t rpm -n iofog-agent -v ${{ steps.pkg_version.outputs.version }} -a all --rpm-os 'linux' --after-install rpm.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade rpm.sh etc usr;
echo "pkg created"
ls
- uses: actions/upload-artifact@v2
name: Upload deb package
with:
name: deb-package
path: packaging/iofog-agent/iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb
- uses: bluwy/substitute-string-action@v1
id: sub
with:
_input-text: ${{ steps.pkg_version.outputs.version }}
'-': _
- run: echo ${{ steps.sub.outputs.result }}
- uses: actions/upload-artifact@v2
name: Upload rpm package
with:
name: rpm-package
path: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm
- uses: actions/download-artifact@v2
with:
name: deb-package
- name: Publish deb package to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb
PACKAGECLOUD-USERNAME: iofog
PACKAGECLOUD-REPO: iofog-agent-dev
PACKAGECLOUD-DISTRIB: any/any
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}
- uses: actions/download-artifact@v2
with:
name: rpm-package
- name: Publish rpm package to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm
PACKAGECLOUD-USERNAME: iofog
PACKAGECLOUD-REPO: iofog-agent-dev
PACKAGECLOUD-DISTRIB: rpm_any/rpm_any
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}
- name: Upload Agent Artifact
uses: actions/upload-artifact@v3
with:
name: agent
path: packaging/**/*
Publish_prod:
runs-on: ubuntu-20.04
needs: [ Build, Integration, Publish_dev ]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
name: Publish_prod
steps:
- run: echo ${{needs.Publish_dev.outputs.version}}
- name : Test
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
echo "I am in the tag"
- uses: actions/download-artifact@v2
with:
name: deb-package
- uses: actions/download-artifact@v2
with:
name: rpm-package
- name: Publish tagged deb package to packagecloud
if: startsWith(github.ref, 'refs/tags/v')
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb
PACKAGECLOUD-USERNAME: iofog
PACKAGECLOUD-REPO: iofog-agent
PACKAGECLOUD-DISTRIB: any/any
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}
- name: Publish tagged rpm package to packagecloud
if: startsWith(github.ref, 'refs/tags/v')
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm
PACKAGECLOUD-USERNAME: iofog
PACKAGECLOUD-REPO: iofog-agent
PACKAGECLOUD-DISTRIB: rpm_any/rpm_any
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}