forked from openDAQ/openDAQ
-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (206 loc) · 8.9 KB
/
Copy pathdeploy.yml
File metadata and controls
242 lines (206 loc) · 8.9 KB
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
name: Deploy openDAQ SDK packages on AWS
on:
workflow_run:
workflows: ["Build openDAQ packages"]
types: [completed]
branches: [main]
workflow_dispatch:
inputs:
run-id:
description: 'Package workflow run ID to deploy from'
required: true
type: string
env:
s3bucket: bb-blueberry-sdk-releases
build_path: ${{ github.workspace }}/build
jobs:
resolve:
runs-on: ubuntu-latest
name: Resolve build context
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
outputs:
branch: ${{ steps.resolve.outputs.branch }}
ref: ${{ steps.resolve.outputs.ref }}
run-id: ${{ steps.resolve.outputs.run-id }}
steps:
- name: Resolve source context
id: resolve
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "workflow_run" ]; then
REF="${{ github.event.workflow_run.head_sha }}"
BRANCH="${{ github.event.workflow_run.head_branch }}"
RUN_ID="${{ github.event.workflow_run.id }}"
else
RUN_ID="${{ inputs.run-id }}"
RUN_INFO=$(gh api repos/${{ github.repository }}/actions/runs/${RUN_ID})
REF=$(echo "$RUN_INFO" | jq -r '.head_sha')
BRANCH=$(echo "$RUN_INFO" | jq -r '.head_branch')
fi
echo "ref=$REF" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "run-id=$RUN_ID" >> $GITHUB_OUTPUT
echo "Source context: ref=$REF, branch=$BRANCH, run-id=$RUN_ID"
prepare_doc:
runs-on: ubuntu-latest
name: Build User Guide
needs: [resolve]
outputs:
examples-artifact-name: ${{ steps.examples.outputs.artifact-name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.ref }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '16'
- name: Install Antora
run: npm i antora
- name: Install Antora extensions
run: |
npm i @asciidoctor/tabs
npm i @springio/antora-extensions
npm i @antora/lunr-extension
- name: Run Antora to build user guide
run: |
case "${{ needs.resolve.outputs.branch }}" in
release/*)
npx antora antora-playbook.yml
;;
*)
npx antora antora-playbook-dev.yml
;;
esac
- name: Compress user guide
working-directory: ${{ env.build_path }}/site/
run: zip -r ${{ env.build_path }}/user_guide.zip .
- name: Upload user guide
uses: actions/upload-artifact@v4
with:
name: user_guide
path: ${{ env.build_path }}/user_guide.zip
retention-days: 7
- name: Call the API to deploy the documentation
run: |
BRANCH="${{ needs.resolve.outputs.branch }}"
case "$BRANCH" in
main)
wget ${{ secrets.DEPLOY_DEV_DOCUMENTATION_URL_AND_TOKEN }}
;;
release/*)
wget ${{ secrets.DEPLOY_DOCUMENTATION_URL_AND_TOKEN }}
;;
*)
echo "::warning::Branch '$BRANCH' is not a release or dev branch, skipping documentation deploy"
;;
esac
- name: Detect version
id: detect
uses: ./.github/actions/package-version-detect
- name: Build examples archive
id: examples
run: |
EXAMPLES_NAME="opendaq-${{ steps.detect.outputs.version-full }}-examples"
zip -r "${EXAMPLES_NAME}.zip" examples/applications -x examples/applications/CMakeLists.txt
echo "artifact-name=$EXAMPLES_NAME" >> $GITHUB_OUTPUT
echo "artifact-path=${EXAMPLES_NAME}.zip" >> $GITHUB_OUTPUT
- name: Upload examples
uses: actions/upload-artifact@v4
with:
name: ${{ steps.examples.outputs.artifact-name }}
path: ${{ steps.examples.outputs.artifact-path }}
retention-days: 7
deploy_packages:
runs-on: ubuntu-latest
name: Deploy packages to S3
needs: [resolve, prepare_doc]
env:
RUN_ID: ${{ needs.resolve.outputs.run-id }}
BRANCH: ${{ needs.resolve.outputs.branch }}
DOWNLOAD_PATH: ${{ github.workspace }}/_artifacts/download
DST_ROOT_DIR: releases
SDK_DIR: SDK
WHEELS_LINUX_X64_DIR: Python Wheels (Linux x86_64)
WHEELS_WINDOWS_X64_DIR: Python Wheels (Windows amd64)
WHEELS_MACOS_X64_DIR: Python Wheels (MacOS x86_64)
WHEELS_MACOS_ARM_DIR: Python Wheels (MacOS ARM)
DOTNET_DIR: dotNET Bindings
SIMULATOR_DIR: Simulator
DOC_DIR: Specifications and documentation
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ env.RUN_ID }}
path: ${{ env.DOWNLOAD_PATH }}
- name: Download user guide
uses: actions/download-artifact@v4
with:
name: user_guide
path: ${{ env.DOWNLOAD_PATH }}
- name: Download examples
uses: actions/download-artifact@v4
with:
name: ${{ needs.prepare_doc.outputs.examples-artifact-name }}
path: ${{ env.DOWNLOAD_PATH }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload to S3
run: |
SRC="${DOWNLOAD_PATH}"
S3_PATH="${DST_ROOT_DIR}/${BRANCH}"
DST_URI="s3://${{ env.s3bucket }}/${S3_PATH}"
echo '#### Downloaded artifacts' | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
tree -F ${SRC} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# SDK packages
aws s3 rm "${DST_URI}/${SDK_DIR}/" --recursive --exclude '*' \
--include 'opendaq-*_win_*.exe' \
--include 'opendaq-*_win_*.zip' \
--include 'opendaq-*_linux_*.deb' \
--include 'opendaq-*_linux_*.zip' \
--include 'opendaq-*-examples.zip'
for f in "${SRC}"/opendaq-*_win_*/*.exe \
"${SRC}"/opendaq-*_linux_*/*.deb \
"${SRC}"/opendaq-*-examples*.zip; do
aws s3 cp "$f" "${DST_URI}/${SDK_DIR}/"
done
# Python Wheels
aws s3 rm "${DST_URI}/${WHEELS_LINUX_X64_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 cp "${SRC}"/opendaq-*-python-wheels-linux/ "${DST_URI}/${WHEELS_LINUX_X64_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 rm "${DST_URI}/${WHEELS_WINDOWS_X64_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 cp "${SRC}"/opendaq-*-python-wheels-windows/ "${DST_URI}/${WHEELS_WINDOWS_X64_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 rm "${DST_URI}/${WHEELS_MACOS_X64_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 cp "${SRC}"/opendaq-*-python-wheels-macos-x86_64/ "${DST_URI}/${WHEELS_MACOS_X64_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 rm "${DST_URI}/${WHEELS_MACOS_ARM_DIR}/" --recursive --exclude '*' --include '*.whl'
aws s3 cp "${SRC}"/opendaq-*-python-wheels-macos-arm64/ "${DST_URI}/${WHEELS_MACOS_ARM_DIR}/" --recursive --exclude '*' --include '*.whl'
# NuGet
aws s3 rm "${DST_URI}/${DOTNET_DIR}/" --recursive --exclude '*' --include '*.nupkg'
aws s3 cp "${SRC}"/opendaq.net-*/ "${DST_URI}/${DOTNET_DIR}/" --recursive --exclude '*' --include '*.nupkg'
# Simulator
aws s3 rm "${DST_URI}/${SIMULATOR_DIR}/" --recursive --exclude '*' --include '*.ova'
aws s3 cp "${SRC}"/opendaq-*_device_simulator*/ "${DST_URI}/${SIMULATOR_DIR}/" --recursive --exclude '*' --include '*.ova'
# Documentation
aws s3 rm "${DST_URI}/${DOC_DIR}/" --recursive --exclude '*' --include 'cpp_api_reference.zip' --include 'user_guide.zip'
aws s3 cp "${SRC}/API Reference/opendaq_cpp_api_reference.zip" "${DST_URI}/${DOC_DIR}/cpp_api_reference.zip"
aws s3 cp "${SRC}/user_guide.zip" "${DST_URI}/${DOC_DIR}/"
# Publish a report of the uploaded artifacts
echo "#### S3 Artifacts tree: ${S3_PATH:-/}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
aws s3 ls "${DST_URI}" --recursive \
| awk '/^ *PRE / { sub(/^ *PRE /, ""); print; next } { $1=$2=$3=""; sub(/^ +/, ""); print }' \
| sed "s|^${S3_PATH:+${S3_PATH}/}||" \
> /tmp/s3tree.txt
tree --fromfile /tmp/s3tree.txt --noreport -F | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY