This repository has been archived by the owner on Mar 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
84 lines (79 loc) · 2.97 KB
/
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
name: Build/Release
on:
pull_request:
paths-ignore:
- "nuxt/**"
push:
branches: master
paths-ignore:
- "nuxt/**"
jobs:
release:
runs-on: ${{ matrix.os }}
# Platforms to build on/for
strategy:
matrix:
os: [windows-2019, ubuntu-18.04]
steps:
- uses: actions/checkout@v1
- name: Set version in Env
shell: bash
run: |
package_version=`awk -F ':' '/version/ {print $2}' package.json | sed 's/\"//g' | sed 's/,//g' | sed 's/ //g'`
echo "package_version=$package_version" >> $GITHUB_ENV
echo "Version is $package_version"
- uses: actions/[email protected]
name: Check if current version is a published release (by release tag)
id: check_release
with:
github-token: ${{secrets.GITHUB_TOKEN}}
# debug: true
script: |
const releases = await github.repos.listReleases({
owner: 'baruchiro',
repo: 'israeli-bank-scrapers-desktop'
})
// console.log(releases)
const published_release_tags = releases.data.filter(release => !release.draft).map(release => release.tag_name)
// console.log(published_release_tags)
// github.event_name: ${{ github.event_name }}
// github.ref: ${{ github.ref }}
const isPushToMaster = ${{ startsWith(github.event_name, 'push') && github.ref == 'refs/heads/master' }}
console.log('Is push to mster: ' + isPushToMaster)
const publishToRelease = !published_release_tags.includes('v${{ env.package_version }}') && isPushToMaster
console.log('publishToRelease: ' + publishToRelease)
return publishToRelease
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 10
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@10d7d0a84d9d86098b19f872257df314b0bd8e2d
# Only install Snapcraft on Ubuntu
if: startsWith(matrix.os, 'ubuntu')
with:
snapcraft_token: ${{ secrets.snapcraft_token }}
- name: Set 'publish' parameter
shell: python
run: |
import os
param = 'always' if '${{ steps.check_release.outputs.result }}' == 'true' else 'never'
print("Will {} (for this run) publish files to draft release".format(param))
with open(os.getenv('GITHUB_ENV'), 'a') as envFile: envFile.write('PUBLISH_PARAM=' + param)
- name: Build & release Electron app
shell: bash
env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max-old-space-size=4096
run: |
yarn
yarn build --publish $PUBLISH_PARAM
- name: Upload artifact
uses: actions/[email protected]
with:
# Artifact name
name: ${{ matrix.os }}-artifact
# Directory containing files to upload
path: dist_electron