-
-
Notifications
You must be signed in to change notification settings - Fork 32
237 lines (201 loc) · 6.69 KB
/
build-and-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
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
name: build and release
on:
push:
branches:
- '*'
tags:
- '*'
pull_request:
branches: [ master ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
pre-build:
name: pre-build
runs-on: "ubuntu-latest"
outputs:
current_branch_tag: ${{steps.branch_name.outputs.current_branch_tag}}
is_tag: ${{steps.branch_name.outputs.is_tag}}
steps:
- name: Get branch/tag name
id: branch_name
run: |
echo "current_branch_tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
[[ "${GITHUB_REF_TYPE}" == "tag" ]] && echo "is_tag=true" >> $GITHUB_OUTPUT || echo "is_tag=false" >> $GITHUB_OUTPUT
- name: Echo pre_build
run: |
echo ${{ steps.branch_name.outputs.is_tag }} ${{ steps.branch_name.outputs.current_branch_tag }}
echo ${{ github.ref}}
build-web-app:
name: build-web-app
runs-on: "ubuntu-latest"
needs: [pre-build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '19'
- name: show gitref / tags
run: echo ${{ github.ref }} ${{needs.pre-build.outputs.current_branch_tag}} ${{needs.pre-build.outputs.is_tag}}
- run: npm install
working-directory: WebApplication
- run: npm run build
working-directory: WebApplication
- name: upload web-app-dist to s3
working-directory: WebApplication
run: zip -r ${{needs.pre-build.outputs.current_branch_tag}}.zip dist/ && aws s3 --region eu-west-1 cp ${{needs.pre-build.outputs.current_branch_tag}}.zip s3://public-files.orthanc.team/oe2-dist-files/ --cache-control max-age=1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- uses: actions/upload-artifact@v4
with:
name: web-app-dist
path: WebApplication/dist/
if-no-files-found: error
build:
name: ${{ matrix.config.os }}-build
runs-on: ${{ matrix.config.os }}
needs: [pre-build, build-web-app]
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows",
artifact: "OrthancExplorer2.dll",
artifactPath: "Release\\OrthancExplorer2.dll",
triplet: x64-windows,
os: windows-latest,
extraCMakeFlags: ""
}
- {
name: "Ubuntu",
artifact: "libOrthancExplorer2.so",
artifactPath: "libOrthancExplorer2.so",
triplet: x64-linux,
os: ubuntu-latest,
extraCMakeFlags: ""
}
- {
name: "MacOSX",
artifact: "libOrthancExplorer2.dylib",
artifactPath: "libOrthancExplorer2.dylib",
triplet: x64-osx,
os: macos-13,
extraCMakeFlags: "-DUSE_LEGACY_BOOST=ON"
}
steps:
- uses: actions/checkout@v4
- name: show gitref / tags
run: echo ${{ github.ref }} ${{needs.pre-build.outputs.current_branch_tag}} ${{needs.pre-build.outputs.is_tag}}
- uses: actions/download-artifact@v4
id: download
with:
name: web-app-dist
path: WebApplication/dist
- name: install Mercurial on MacOS
if: runner.os == 'MacOS'
run: pip3 install mercurial --break-system-packages
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build ${{matrix.config.extraCMakeFlags}} -DPLUGIN_VERSION="${{needs.pre-build.outputs.current_branch_tag}}" -DSTATIC_BUILD=ON -DALLOW_DOWNLOADS=ON -DUSE_SYSTEM_ORTHANC_SDK=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWEBAPP_DIST_SOURCE=WEB
env:
MAKEFLAG: -j4
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
env:
MAKEFLAG: -j4
- name: Upload
uses: actions/upload-artifact@v4
with:
path: ${{github.workspace}}/build/${{matrix.config.artifactPath}}
name: ${{matrix.config.artifact}}
if-no-files-found: error
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
timeout-minutes: 20
check-translations:
name: check-translations
runs-on: "ubuntu-latest"
needs: [pre-build]
steps:
- uses: actions/checkout@v4
- run: python3 ./scripts/check-translations.py
release:
needs: [build, pre-build]
if: needs.pre-build.outputs.is_tag == 'true'
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ needs.pre-build.outputs.current_branch_tag }}
name: Release ${{ needs.pre-build.outputs.current_branch_tag }}
draft: false
prerelease: false
- name: Store Release url
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- uses: actions/upload-artifact@v4
with:
path: ./upload_url
name: upload_url
if-no-files-found: error
publish:
name: ${{ matrix.config.name }}
needs: [pre-build, release]
if: needs.pre-build.outputs.is_tag == 'true'
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows",
artifact: "OrthancExplorer2.dll",
artifact_name: "OrthancExplorer2-win64.dll",
os: ubuntu-latest
}
- {
name: "Ubuntu",
artifact: "libOrthancExplorer2.so",
artifact_name: "libOrthancExplorer2-ubuntu.so",
os: ubuntu-latest
}
- {
name: "MacOSX",
artifact: "libOrthancExplorer2.dylib",
artifact_name: "libOrthancExplorer2-universal.dylib",
os: ubuntu-latest
}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.config.artifact }}
path: ./
- name: Download URL
uses: actions/download-artifact@v4
with:
name: upload_url
path: ./
- id: set_upload_url
run: |
upload_url=`cat ./upload_url`
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
- name: Upload to Release
id: upload_to_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ./${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact_name }}
asset_content_type: application/octet-stream