mattermost-desktop/.circleci/config.yml
Carlos Tadeu Panato Junior f6aec188ce update context (#1120)
2019-12-04 15:42:52 +01:00

336 lines
9.6 KiB
YAML

version: 2.1
orbs:
win: circleci/windows@1.0.0
aws-s3: circleci/aws-s3@1.0.11
executors:
wine-chrome:
working_directory: ~/mattermost-desktop
docker:
- image: electronuserland/builder:wine-chrome
environment:
TAR_OPTIONS: --no-same-owner
wine-mono:
working_directory: ~/mattermost-desktop
docker:
- image: electronuserland/builder:wine-mono
mac:
working_directory: ~/mattermost-desktop
macos:
xcode: "10.3.0"
aws:
working_directory: ~/mattermost-desktop
docker:
- image: 'circleci/python:2.7'
github:
working_directory: ~/mattermost-desktop
docker:
- image: circleci/golang:1.12
commands:
update_image:
description: "Update base image"
parameters:
apt_opts:
type: string
default: ""
steps:
- run: apt-get update && apt-get -y install << parameters.apt_opts >>
- run: npm install
win_make:
description: "Run mattermost's makefile.ps1 on ./scripts/"
parameters:
operation:
type: string
default: ""
steps:
- run:
command: ./scripts/Makefile.ps1 << parameters.operation >>
name: << parameters.operation >>
shell: powershell
build:
description: "Building << parameters.os >> app"
parameters:
os:
type: string
default: "linux"
path:
type: string
default: "./dist/linux"
subpath:
type: string
default: "./linux/"
steps:
- run: npm run build
- run: npm run package:<< parameters.os >>
- run: mkdir -p << parameters.path >>
- run: bash -x ./scripts/cp_artifacts.sh release << parameters.path >>
- persist_to_workspace:
root: ./dist
paths:
- "./<< parameters.subpath >>/"
jobs:
check:
executor: wine-chrome
steps:
- checkout
- update_image:
apt_opts: "--no-install-recommends"
- restore_cache:
key: lint-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
- run: npm run lint:js-quiet
- run: ELECTRON_DISABLE_SANDBOX=1 xvfb-run npm run test:app
- run: mkdir -p /tmp/test-results
- run: cp test-results.xml /tmp/test-results/
- store_test_results:
path: /tmp/test-results
- save_cache:
key: lint-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- "node_modules"
- "src/node_modules"
build-linux:
executor: wine-mono
steps:
- checkout
- run: mkdir -p ./dist
- attach_workspace:
at: ./dist
- restore_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
- restore_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "src/package-lock.json" }}
- update_image:
apt_opts: "--no-install-recommends jq icnsutils graphicsmagick tzdata"
- build
- save_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- "node_modules"
- "~/.cache/electron"
- "~/.cache/electron-builder"
- save_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "src/package-lock.json" }}
paths:
- "src/node_modules"
build-win-no-installer:
executor: wine-mono
steps:
- checkout
- run: mkdir -p ./dist
- attach_workspace:
at: ./dist
- restore_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
- restore_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "src/package-lock.json" }}
- update_image:
apt_opts: "--no-install-recommends jq icnsutils graphicsmagick tzdata"
- build:
os: windows
path: ./dist/win
subpath: ./win/
- save_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- "node_modules"
- "~/.cache/electron"
- "~/.cache/electron-builder"
- save_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "src/package-lock.json" }}
paths:
- "src/node_modules"
build-mac-no-dmg:
executor: wine-mono
steps:
- checkout
- run: mkdir -p ./dist
- attach_workspace:
at: ./dist
- restore_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
- restore_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "src/package-lock.json" }}
- update_image:
apt_opts: "--no-install-recommends jq icnsutils graphicsmagick tzdata"
- run: jq '.mac.target=["zip"]' electron-builder.json | jq '.mac.gatekeeperAssess=false' > /tmp/electron-builder.json && cp /tmp/electron-builder.json .
- build:
os: mac
path: ./dist/macos
subpath: ./macos/
- save_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- "node_modules"
- "~/.cache/electron"
- "~/.cache/electron-builder"
- save_cache:
key: npm-{{ arch }}-{{ .Branch }}-{{ checksum "src/package-lock.json" }}
paths:
- "src/node_modules"
msi_installer:
executor: win/vs2019
steps:
- checkout
- run: mkdir -p ./dist/
- attach_workspace:
at: ./dist
- win_make:
operation: optimize
- win_make:
operation: "install-deps"
- win_make:
operation: "build"
- run: mkdir -p ./dist/win-release
#- run: cp -r release/*.exe ./dist/win-release
- run: cp -r release/*.zip ./dist/win-release
- run: cp -r release/*.msi ./dist/win-release
#- run: cp -r release/*.blockmap ./dist/win-release
- persist_to_workspace:
root: ./dist/
paths:
- "./win-release/"
mac_installer:
executor: mac
steps:
- checkout
- run: mkdir -p ./dist
- attach_workspace:
at: ./dist
- run:
name: Installing npm dependencies
command: npm install
- build:
os: mac
path: ./dist/macos-release
subpath: ./macos-release/
store_artifacts:
executor: wine-chrome
steps:
- attach_workspace:
at: ./dist
- store_artifacts:
path: ./dist
destination: packages
upload_to_s3:
executor: aws
steps:
- checkout
- attach_workspace:
at: ./dist
- aws-s3/copy:
from: ./dist/
to: s3://releases.mattermost.com/desktop/$(jq -r .version package.json)/
arguments: --acl public-read --cache-control "no-cache" --recursive
upload_to_github:
executor: github
steps:
- checkout
- attach_workspace:
at: ./dist
- run:
name: "Setup files for ghr"
command: |
mkdir -p ./ghr-dist
cp ./dist/{macos-release,win-release,linux}/* ./ghr-dist
- run:
name: "Publish Release on GitHub"
command: |
go get github.com/tcnksm/ghr
VERSION=$(jq -r .version package.json)
RELEASE_TITLE="${VERSION} ($(date -u "+%Y-%m-%d"))"
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -draft \
--body="$(./scripts/generate_release_markdown.sh $VERSION)" \
--name="${RELEASE_TITLE}" $( [[ $VERSION =~ "-rc" ]] && printf %s "-prerelease") \
-r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} \
-delete ${VERSION} ./ghr-dist
workflows:
version: 2
build_and_test:
jobs:
- check
- build-linux:
requires:
- check
- build-win-no-installer:
requires:
- check
filters:
branches:
ignore:
- /^release-\d+\.\d+\.\d+?(-rc.*)?/
- build-mac-no-dmg:
requires:
- check
filters:
branches:
ignore:
- /^release-\d+\.\d+(\.\d+)?(-rc.*)?/
- msi_installer:
requires:
- check
context: windows-codesign
filters:
branches:
only:
# only for release and release candidates
# release-XX.YY.ZZ
# release-XX.YY.ZZ-rc-something
- /^release-\d+\.\d+\.\d+?(-rc.*)?/
- release-helpers # remove me
- mac_installer:
requires:
- check
context: codesign-certificates
filters:
branches:
only:
- /^release-\d+\.\d+\.\d+?(-rc.*)?/
- release-helpers # remove-me
- store_artifacts:
# for master/PR builds
requires:
- build-linux
- build-win-no-installer
- build-mac-no-dmg
filters:
branches:
ignore:
- /^release-\d+\.\d+\.\d+?(-rc.*)?/
- upload_to_s3:
# for release builds
requires:
- msi_installer
- mac_installer
- build-linux
context: mattermost-release-s3
filters:
tags:
only:
- /^v\d+\.\d+\.\d+?$/
- release-helpers # remove me
- upload_to_github:
requires:
- msi_installer
- mac_installer
- build-linux
context: matterbuild-github-token
filters:
branches:
only:
- /^release-\d+\.\d+\.\d+?(-rc.*)?/
- release-helpers # remove me