-
-
Notifications
You must be signed in to change notification settings - Fork 8
352 lines (325 loc) · 15.3 KB
/
master.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
name: Build
on:
push:
# pull_request:
# We need two jobs: First a build-job, running on a matrix
# to build all necessary releases, which also uploads all
# resulting assets to the workflow. And then, we download
# them onto a separate VM running the release-job to verify
# the checksums and create a draft release.
jobs:
prepare_docs:
# needs: [build] # Make sure (and wait until) the build has succeeded
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' && false
steps:
- uses: actions/checkout@v2
- run: |
ls app
rm -rf docs
mkdir docs
- name: JSDoc Action
# You may pin to the exact commit or the version.
# uses: andstor/jsdoc-action@2fb2b536605bdebace2b92abb0601155d5ddc688
uses: andstor/jsdoc-action@v1.2.0
with:
# Source directory to build documentation from
source_dir: app
# Output folder for the generated documentation
output_dir: docs
# Recurse into subdirectories when scanning for source files
recurse: true
# The path to a JSDoc configuration file
# config_file: # optional
# The path to a Markdown file to be used as a the front page
front_page: README.md
- run: ls docs
- name: Git Commit and Push
uses: github-actions-x/commit@v2.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "ci: commit the generated documentation to /docs"
# Force add files, useful for adding ignored files.
force-add: # optional, default is false
files: docs/*
name: GitHub Actions
email: action@github.com
release_management:
# needs: [prepare_docs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
if: github.ref == 'refs/heads/master'
- name: Setting up Node
uses: actions/setup-node@v1
if: github.ref == 'refs/heads/master'
with:
node-version: '10.15.1'
- name: Preparing release
if: github.ref == 'refs/heads/master'
#--prerelease alpha --skip.tag --release-as 0.2.0
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
pushd ./app
npx standard-version -a --no-verify --prerelease beta --skip.changelog --skip.tag
echo ::set-env name=PACKAGE_VERSION::$(node -p -e "require('./package.json').version")
popd
npx standard-version -a --no-verify --prerelease beta --skip.tag
env:
CI: true
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Push to master
if: github.ref == 'refs/heads/master'
uses: ad-m/github-push-action@v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# - name: Merge back to develop
# uses: ad-m/github-push-action@v0.5.0
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: develop
build:
needs: [release_management]
strategy:
matrix:
os: [ubuntu-latest, windows-latest, ubuntu-18.04]
# Define the operating system
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup NodeJS 12.x
uses: actions/setup-node@v1
if: matrix.os != 'ubuntu-18.04'
with:
node-version: '10.15.0'
- name: Get version numbers from package.json
id: pkg
run: |
appver=$(node -p -e "require('./app/package.json').version")
pkgver=$(node -p -e "require('./package.json').version")
echo ::set-output name=version::$appver
echo ::set-output name=package_version::$pkgver
shell: bash
# On Windows server, we have to create the handlebars-directory
# manually, because the node-process always crashes when it
# attempts literally the same thing.
- name: "[Windows] Manually create the handlebars-directory"
if: matrix.os == 'windows-latest'
run: New-Item -Path "./source/common/assets" -Name "handlebars" -ItemType "directory" # Hello, PowerShell ._.
- name: Get yarn cache directory path
id: yarn-cache-dir-path
if: matrix.os != 'ubuntu-18.04'
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache
id: cache-yarn
uses: actions/cache@v2.1.1
with:
path: '**/node_modules'
key: ${{ runner.os }}-cache-${{ matrix.os }}-${{ hashFiles('**/yarn.lock') }}
- name: "[All except docker] Set up build environment and compile the assets"
if: steps.cache-yarn.outputs.cache-hit != 'true' && matrix.os != 'ubuntu-18.04' # all except the docker build
run: |
yarn
pushd app
yarn
popd
- name: "[All except docker] Print Cache dirs"
if: matrix.os != 'ubuntu-18.04'
run: |
pwd
# ls -f .
# ls -l ~/work/notorious/notorious/npm_modules
# ls -l ~/work/notorious/notorious/app/npm_modules
# WINDOWS ==============================================================
- name: "[Windows Build] Build & Publish Windows Installer"
if: matrix.os == 'windows-latest' && github.ref == 'refs/heads/master'
run: yarn package-win
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "[Windows Build] Build Windows Installer"
if: matrix.os == 'windows-latest' && github.ref != 'refs/heads/master'
run: yarn package-win-build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # MACOS ================================================================
# # - name: Build macOS DMG file
# # if: matrix.os == 'macos-latest' # Only if the job runs on macOS
# # run: GH_TOKEN=${{ secrets.GITHUB_TOKEN }} APPLE_ID=${{ secrets.APPLE_ID }} APPLE_ID_PASS=${{ secrets.APPLE_ID_PASS }} CSC_LINK=${{ secrets.MACOS_CERT }} CSC_KEY_PASSWORD=${{ secrets.MACOS_CERT_PASS }} npm run release:mac
# # - name: Cache macOS release
# # if: matrix.os == 'macos-latest' # Only if the job runs on macOS
# # uses: actions/upload-artifact@v1
# # with:
# # name: Notorious-${{ steps.pkg.outputs.version }}.dmg
# # path: ./release/Notorious-${{ steps.pkg.outputs.version }}.dmg
# LINUX ================================================================
- name: "[Linux Build] Build & Publish Linux installers"
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master'
run: GH_TOKEN=${{ secrets.GITHUB_TOKEN }} yarn package-linux
- name: "[Linux Build] Build Linux installers"
if: matrix.os == 'ubuntu-latest' && github.ref != 'refs/heads/master'
run: |
ls node_modules
GH_TOKEN=${{ secrets.GITHUB_TOKEN }} yarn package-linux-build
# LINUX DOCKER ================================================================
- name: "[Docker Build] Login to DockerHub Registry"
if: matrix.os == 'ubuntu-18.04'
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: "[Docker Build] Build the tagged Docker image"
if: matrix.os == 'ubuntu-18.04' && github.ref == 'refs/heads/master'
run: docker build . --file Dockerfile.prod --tag danobot/notorious:${{ steps.pkg.outputs.version }} && docker tag danobot/notorious:${{ steps.pkg.outputs.version }} danobot/notorious:latest
- name: "[Docker Build] Build the tagged Docker image"
if: matrix.os == 'ubuntu-18.04' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop'
run: docker build . --file Dockerfile.prod --tag danobot/notorious:${{ steps.pkg.outputs.version }} && docker tag danobot/notorious:${{ steps.pkg.outputs.version }} danobot/notorious:latest
- name: "[Docker Build] Push the tagged Docker image"
if: matrix.os == 'ubuntu-18.04' && github.ref == 'refs/heads/master'
run: docker push danobot/notorious:${{ steps.pkg.outputs.version }}
- name: "[Docker Build Develop] Build the latest Docker image"
if: matrix.os == 'ubuntu-18.04' && github.ref == 'refs/heads/develop'
run: docker build . --file Dockerfile.prod --tag danobot/notorious:next
- name: "[Docker Build Develop] Push the latest Docker image"
if: matrix.os == 'ubuntu-18.04' && github.ref == 'refs/heads/develop'
run: docker push danobot/notorious:next
# As soon as the build matrix has completed correctly, this job will
# commence, creating a new draft release, downloading all assets from
# the previous job, verifying the checksum integrity, and uploading that
# whole mess to the draft release.
# prepare_docs:
# needs: [build] # Make sure (and wait until) the build has succeeded
# runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/develop'
# steps:
# # Clone the repository to get the ./scripts/get-pkg-version.js and the ./package.json
# - uses: actions/checkout@v2
# # Setup node to run the retrieval script
# - name: Setup NodeJS 12.x
# uses: actions/setup-node@v1
# with:
# node-version: '10.15.0'
# - name: Retrieve the current package version
# id: pkg
# run: |
# pkgver=$(node -p -e "require('./app/package.json').version")
# echo ::set-output name=version::$pkgver
# # Now, download all resulting assets from the previous steps.
# - name: Download the Windows asset
# uses: actions/download-artifact@v1
# with:
# name: Notorious-${{ steps.pkg.outputs.version }}.exe
# path: .
# # - name: Download the macOS asset
# # uses: actions/download-artifact@v1
# # with:
# # name: Notorious-${{ steps.pkg.outputs.version }}.dmg
# # path: .
# - name: Download the Debian asset
# uses: actions/download-artifact@v1
# with:
# name: Notorious-${{ steps.pkg.outputs.version }}-amd64.deb
# path: .
# - name: Download the Fedora asset
# uses: actions/download-artifact@v1
# with:
# name: Notorious-${{ steps.pkg.outputs.version }}-x86_64.rpm
# path: .
# - name: Download the AppImage (x32) asset
# uses: actions/download-artifact@v1
# with:
# name: Notorious-${{ steps.pkg.outputs.version }}-i386.AppImage
# path: .
# # - name: Download the AppImage (x64) asset
# # uses: actions/download-artifact@v1
# # with:
# # name: Notorious-${{ steps.pkg.outputs.version }}-x86_64.AppImage
# # path: .
# # Now we are set, we have all five release assets on the VM. It's time to create the
# # SHA-checksums file and then upload everything!
# - name: Generate SHA256 checksums
# run: |
# ls -la
# sha256sum "Notorious Setup ${{ steps.pkg.outputs.version }}.exe" > "SHA256SUMS.txt"
# # sha256sum "Notorious-${{ steps.pkg.outputs.version }}.dmg" >> "SHA256SUMS.txt"
# sha256sum "notorious_${{ steps.pkg.outputs.version }}_amd64.deb" >> "SHA256SUMS.txt"
# sha256sum "notorious-${{ steps.pkg.outputs.version }}.x86_64.rpm" >> "SHA256SUMS.txt"
# sha256sum "Notorious-${{ steps.pkg.outputs.version }}.AppImage" >> "SHA256SUMS.txt"
# # sha256sum "Notorious-${{ steps.pkg.outputs.version }}-x86_64.AppImage" >> "SHA256SUMS.txt"
# - name: Verify checksums
# run: |
# ls -la
# sha256sum -c SHA256SUMS.txt
# # Create a new release draft
# - name: Create a new release draft
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ steps.pkg.outputs.version }} # tag_name is required, but can be overridden during edit
# release_name: v${{ steps.pkg.outputs.version }} # release_name is required
# body: If you can read this, we have forgotten to fill in the changelog. Sorry!
# draft: true # Always create as draft, so that we can populate the remaining values easily
# # And finally, upload that shit
# - name: Upload Windows asset
# uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./Notorious Setup ${{ steps.pkg.outputs.version }}.exe
# asset_name: Notorious-${{ steps.pkg.outputs.version }}.exe
# asset_content_type: application/x-msdownload
# # - name: Upload macOS asset
# # uses: actions/upload-release-asset@v1.0.1
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # with:
# # upload_url: ${{ steps.create_release.outputs.upload_url }}
# # asset_path: ./Notorious-${{ steps.pkg.outputs.version }}.dmg
# # asset_name: Notorious-${{ steps.pkg.outputs.version }}.dmg
# # asset_content_type: application/octet-stream
# - name: Upload Debian asset
# uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./notorious_${{ steps.pkg.outputs.version }}_amd64.deb
# asset_name: Notorious-${{ steps.pkg.outputs.version }}-amd64.deb
# asset_content_type: application/octet-stream
# - name: Upload Fedora asset
# uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./notorious-${{ steps.pkg.outputs.version }}.x86_64.rpm
# asset_name: Notorious-${{ steps.pkg.outputs.version }}-x86_64.rpm
# asset_content_type: application/octet-stream
# - name: Upload AppImage (x32) asset
# uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./Notorious-${{ steps.pkg.outputs.version }}.AppImage
# asset_name: Notorious-${{ steps.pkg.outputs.version }}-i386.AppImage
# asset_content_type: application/octet-stream
# # - name: Upload AppImage (x64) asset
# # uses: actions/upload-release-asset@v1.0.1
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # with:
# # upload_url: ${{ steps.create_release.outputs.upload_url }}
# # asset_path: ./Notorious-${{ steps.pkg.outputs.version }}-x86_64.AppImage
# # asset_name: Notorious-${{ steps.pkg.outputs.version }}-x86_64.AppImage
# # asset_content_type: application/octet-stream
# - name: Upload the checksums
# uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./SHA256SUMS.txt
# asset_name: SHA256SUMS.txt
# asset_content_type: text/plain