Skip to content

Commit

Permalink
chore(circleci): improve build process (#1104)
Browse files Browse the repository at this point in the history
* chore(circleci): improve build process

* chore(circleci): update

* circleci

* fix

* fix

* fixx

* fix version

* fix

* fix

* fix command

* fix lib

* fix permissions

* fix lib

* fixtest

* test

* fix

* fix orb

* adjust

* trigger

* add windows

* 32 support

* sudo

* su

* i

* su

* commands

* str

* fix

* f

* ident

* fix

* add libdev

* fix

* remove

* fixx

* win

* test

* add when step

* add mac

* mac permissions

* enable

* fix tests

* trigger

* fix cachce

* remove storing arts

* arts

* chore(circleci): seperate jobs

* add conditional deploy

* update cache values

* add category

* release test

* chore(app): add auto changelog/tagging/bumping and update readme

* fix

* fix cache

* cache test

* store to workspace

* fix path

* fix path

* add checksums job

* test

* fx

* glob

* glob2

* add checksum command

* final test

* fix syntax

* fix syntax

* fix job name

* fix sha func

* fix win

* adjust shasum command

* fix

* fix

* fix

* test

* cleanup

* cleanup

* adjust version

* fix cache issue

* adjust job

* remove redundant command
  • Loading branch information
Maurice Dalderup authored Aug 23, 2019
1 parent a70c856 commit 9f5696e
Show file tree
Hide file tree
Showing 7 changed files with 653 additions and 101 deletions.
160 changes: 101 additions & 59 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Javascript Node CircleCI 2.0 configuration file.
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
version: 2
version: 2.1

orbs:
codecov: codecov/[email protected]

references:
workspace: &workspace ~/repo
Expand All @@ -22,99 +23,140 @@ references:
xcode: '10.3.0'
working_directory: *workspace

commands:
pre:
description: 'Setting up and building environment'
parameters:
sudo:
type: string
default: ''
windows:
type: boolean
default: false
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- v1-dependencies-{{ arch }}

- run: << parameters.sudo >> apt-get -y update
- run: << parameters.sudo >> apt-get -y install libusb-1.0-0
- when:
condition: <<parameters.windows>>
steps:
- run: apt-get -y install libudev-dev libudev-dev:i386 libusb-1.0-0-dev libusb-1.0-0-dev:i386
- run: yarn

jobs:
build:
build_linux:
<<: *container_config
steps:
- pre:
sudo: 'sudo'
- run: yarn dist --linux
- save_cache:
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
paths:
- node_modules
build_win:
<<: *win_config
steps:
- pre:
windows: true
- run: yarn dist --win --x64 --ia32
- save_cache:
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
paths:
- node_modules
build_mac:
<<: *mac_config
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: sudo apt-get -y update
- run: sudo apt-get -y install libudev-dev libusb-1.0-0-dev
- run: yarn install
- run: chmod -R 777 ~/repo
- v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- v1-dependencies-{{ arch }}
- run: yarn
- run: yarn dist --mac
- save_cache:
key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
test:
<<: *container_config
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: sudo apt-get -y update
- run: sudo apt-get -y install libgtk-3-0 libxss1 libgconf-2-4 libnss3 libasound2
- run: yarn test
- pre:
sudo: 'sudo'
- run: yarn codecov
store_artifacts:
- path: artifacts
- destination: yarnpkg
- codecov/upload:
file: ./coverage/lcov.info

deploy_win:
<<: *win_config
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: dpkg --add-architecture i386
- run: apt-get -y update
- run: apt-get -y install libudev-dev libudev-dev:i386 libusb-1.0-0-dev libusb-1.0-0-dev:i386
- run: yarn install
- pre:
windows: true
- run: yarn release:win
- store_artifacts:
path: dist
destination: build
- persist_to_workspace:
root: *workspace
paths:
- dist/*.*

deploy_linux:
<<: *container_config
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: sudo apt-get -y update
- run: sudo apt-get -y install build-essential libudev-dev
- run: yarn install
- pre:
sudo: 'sudo'
- run: yarn release:linux
- store_artifacts:
path: dist
destination: build
- persist_to_workspace:
root: *workspace
paths:
- dist/*.*

deploy_mac:
<<: *mac_config
steps:
- checkout
- restore_cache:
keys:
- v3-dependencies-{{ checksum "package.json" }}
- v3-dependencies-
- run: yarn install
- v1-dependencies-{{ arch }}-{{ checksum "package.json" }}
- v1-dependencies-{{ arch }}
- run: yarn
- run: yarn release:mac
- store_artifacts:
path: dist
destination: build
- persist_to_workspace:
root: *workspace
paths:
- ./dist/*.*

calculate_checksums:
<<: *container_config
steps:
- attach_workspace:
at: *workspace
- run: cd ./dist && shasum -a 256 *.*

workflows:
version: 2
build_test:
build_win:
jobs:
- build
- test:
requires:
- build

- build_win
build_linux:
jobs:
- build_linux
build_mac:
jobs:
- build_mac
unit_tests:
jobs:
- test
deploy:
jobs:
- calculate_checksums:
requires:
- deploy_win
- deploy_linux
- deploy_mac
- deploy_win:
filters:
branches:
Expand Down
13 changes: 13 additions & 0 deletions .versionrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"types": [
{"type": "feat", "section": "Features"},
{"type": "fix", "section": "Bug Fixes"},
{"type": "chore", "section": "Bug Fixes"},
{"type": "docs", "section": "Documentation"},
{"type": "style", "hidden": true},
{"type": "refactor", "hidden": true},
{"type": "perf", "hidden": true},
{"type": "test", "hidden": true},
{"type": "renovate", "hidden": true}
]
}
37 changes: 29 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,48 @@ Resources:

# Releasing

## Windows & Linux
## Automated Deployment

We use [CircleCI](https://circleci.com/gh/nos/client) to automatically create builds based upon git tags.

1. Create a tag, e.g. `v1.0.0`.
1. `git tag -a v1.0.0 -m "release"` - the `v`-prefix is required for auto updates to work
2. `git push origin v1.0.0`
2. Wait for `deploy_win64` and `deploy_linux` jobs to upload the artifacts to Github Release page as a draft.
1. run `yarn release --dry-run` - Note if the output version tag/changelog is correctly generated.
2. run `yarn release` - This will generate the changelog, update the version in package.json and create and push a tag.
3. The deploys jobs will be triggered and upload the artifacts to Github Release page as a draft.

## macOS
## Manual Deployment: macOS

1. Export the following variables:
1. `CSC_LINK` - This is the path to the .p12 certificate file
2. `CSC_KEY_PASSWORD` - This is the password of the .p12 certificate file
3. `CSC_IDENTITY_AUTO_DISCOVERY` - Set to `false` to disable usage of local keychain (By default it looks in your `login` keychain)
4. `GH_TOKEN` - This is used to upload the artifacts to Github
2. Create the distributable, i.e. `yarn dist`.
3. Locate and upload the following files as these are required for the auto-updater to work:
1. `dist/nOS-1.0.0-mac.zip`
2. `dist/nOS-1.0.0-mac.dmg`
3. `dist/nOS-1.0.0-mac.dmg.blockmap`
4. `dist/latest-mac.yml`

##### Generating hashes for the artifacts
- MacOS: `shasum -a 256 ./*` - Where the final argument is the location of the artifacts
## Manual Deployment: Linux

1. Create the distributable, i.e. `yarn dist`.
2. Locate and upload the following files as these are required for the auto-updater to work:
1. `dist/nOS-1.0.0-linux-amd64.snap`
2. `dist/nOS-1.0.0-linux-x86_64.AppImage`
3. `dist/latest-linux.yml`

## Manual Deployment: Windows

1. Export the following variables:
1. `WIN_CSC_LINK` - This is the certificate file in text format
2. `WIN_CSC_KEY_PASSWORD` - This is the password of the certificate file
3. `GH_TOKEN` - This is used to upload the artifacts to Github
2. Create the distributable, i.e. `yarn dist`.
3. Locate and upload the following files as these are required for the auto-updater to work:
1. `dist/nOS-1.0.0-win.exe`
2. `dist/nOS-1.0.0-win.exe.blockmap`
3. `dist/latest.yml`

### Generating hashes for the artifacts

- MacOS/Linux: `shasum -a 256 ./*` - Where the final argument is the location of the artifacts
23 changes: 23 additions & 0 deletions electron-builder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"appId": "io.nos.desktop",
"forceCodeSigning": true,
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
"win": {
"icon": "./static/icons/icon1024x1024.ico",
"timeStampServer": "http://timestamp.globalsign.com/scripts/timstamp.dll"
},
"linux": {
"icon": "./static/icons/icon1024x1024.png"
},
"mac": {
"icon": "./static/icons/icon1024x1024.icns",
"category": "public.app-category.utilities"
},
"directories": {
"buildResources": "static"
},
"files": ["static/**/*"],
"publish": {
"provider": "github"
}
}
29 changes: 5 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
"lint:fix": "yarn lint --fix",
"clean": "rimraf build dist coverage",
"postinstall": "electron-builder install-app-deps",
"release": "yarn clean && yarn build && build",
"release:win": "yarn release --win --x64 --ia32 -p always",
"release:mac": "yarn release --mac -p always",
"release:linux": "yarn release --linux -p always",
"release": "standard-version",
"release:win": "yarn dist --win --x64 --ia32 -p onTag",
"release:mac": "yarn dist --mac -p onTag",
"release:linux": "yarn dist --linux -p onTag",
"snyk-protect": "snyk protect",
"snyk-test": "snyk test"
},
Expand Down Expand Up @@ -134,6 +134,7 @@
"redux-mock-store": "1.5.3",
"rimraf": "3.0.0",
"sass-loader": "7.2.0",
"standard-version": "7.0.0",
"style-loader": "0.23.1",
"stylelint": "10.1.0",
"stylelint-config-recommended-scss": "3.3.0",
Expand All @@ -145,26 +146,6 @@
"webpack-dev-server": "2.11.5",
"webpack-merge": "4.2.1"
},
"build": {
"appId": "io.nos.desktop",
"forceCodeSigning": true,
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
"win": {
"icon": "./static/icons/icon1024x1024.ico"
},
"linux": {
"icon": "./static/icons/icon1024x1024.png"
},
"directories": {
"buildResources": "static"
},
"files": [
"static/**/*"
],
"publish": {
"provider": "github"
}
},
"jest": {
"testMatch": [
"**/__tests__/**/*.test.js"
Expand Down
1 change: 1 addition & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ignoreDeps": ["@ledgerhq/hw-transport-node-hid"],
"schedule": ["on monday"],
"labels": ["Renovate 🌴"],
"semanticCommitType": "renovate",
"statusCheckVerify": true,
"packageRules": [
{
Expand Down
Loading

0 comments on commit 9f5696e

Please sign in to comment.