Skip to content

Commit 538cf7b

Browse files
authored
Merge pull request #77 from thinreports/build/release-and-build-on-github-action
Build and release on CI
2 parents f01e3c1 + d65909f commit 538cf7b

3 files changed

Lines changed: 72 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and release
2+
3+
on:
4+
push:
5+
branches:
6+
- build/**
7+
tags:
8+
- '*'
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
matrix:
16+
os: [macos-latest, ubuntu-latest, windows-latest]
17+
include:
18+
- os: macos-latest
19+
build: macos
20+
- os: ubuntu-latest
21+
build: linux
22+
- os: windows-latest
23+
build: windows
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
28+
- name: Setup Java JDK
29+
uses: actions/setup-java@v1.3.0
30+
with:
31+
java-version: 7
32+
33+
- name: Setup Python
34+
uses: actions/setup-python@v2
35+
with:
36+
python-version: 2.7
37+
38+
- name: Install Node.js
39+
uses: actions/setup-node@v1
40+
with:
41+
node-version: 13
42+
- name: Install npm packages
43+
run: npm install
44+
45+
- name: Compile scripts
46+
run: npm run compile:prod
47+
48+
- name: Build ${{ matrix.build }}
49+
run: npm run build:${{ matrix.build }}
50+
51+
- name: Upload to artifact if not tagged
52+
uses: actions/upload-artifact@v2
53+
if: "!startsWith(github.ref, 'refs/tags')"
54+
with:
55+
name: ${{ matrix.build }}
56+
path: builds/*.zip
57+
58+
- name: Release if tagged
59+
uses: softprops/action-gh-release@v1
60+
if: startsWith(github.ref, 'refs/tags/')
61+
with:
62+
files: builds/*.zip
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
"compile:javascript": "node tasks/compile.javascript.js",
1212
"compile:css": "node tasks/compile.css.js",
1313
"compile:template": "node tasks/compile.template.js",
14+
"compile:prod": "cross-env NODE_ENV=production npm run compile",
1415
"build": "node tasks/build.js",
15-
"release": "cross-env NODE_ENV=production npm run compile && npm run build",
16+
"build:macos": "node tasks/build.js darwin",
17+
"build:windows": "node tasks/build.js win32",
18+
"build:linux": "node tasks/build.js linux",
19+
"release": "npm run compile:prod && npm run build",
1620
"watch": "node tasks/watch.js",
1721
"postinstall": "cd app && npm install"
1822
},

tasks/build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const archiver = require('archiver')
66
const path = require('path')
77
const fs = require('fs')
88

9+
const targetPlatforms = process.argv[2] ? [process.argv[2]] : ['darwin', 'linux', 'win32']
10+
911
const config = {
1012
packager: {
1113
arch: 'x64',
@@ -15,7 +17,7 @@ const config = {
1517
ignore: 'editor/',
1618
out: path.join(where.root, 'builds'),
1719
overwrite: true,
18-
platform: ['darwin', 'linux', 'win32']
20+
platform: targetPlatforms
1921
},
2022
packageName: {
2123
'Thinreports Editor-darwin-x64': 'ThinreportsEditor-mac',

0 commit comments

Comments
 (0)