9f82808199
* add rename * remove check so we can test it * revert testing changes Co-authored-by: = <=>
503 lines
16 KiB
YAML
503 lines
16 KiB
YAML
version: 2.1
|
|
parameters:
|
|
run_nightly:
|
|
default: false
|
|
type: boolean
|
|
orbs:
|
|
win: circleci/windows@1.0.0
|
|
aws-s3: circleci/aws-s3@2.0.0
|
|
owasp: entur/owasp@0.0.10
|
|
|
|
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:
|
|
notify:
|
|
description: "notify on release channel"
|
|
parameters:
|
|
message:
|
|
type: string
|
|
default: "This is the default notification message, someone forgot to add info on what to notify!"
|
|
username:
|
|
type: string
|
|
default: "MattermostRelease"
|
|
icon:
|
|
type: string
|
|
default: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png"
|
|
steps:
|
|
- run:
|
|
command: |
|
|
export VERSION=$(jq -r .version package.json)
|
|
echo '{}' | jq "{
|
|
\"username\": \"<< parameters.username >>\",
|
|
\"icon_url\": \"<< parameters.icon >>\",
|
|
\"text\": \"[${VERSION}] << parameters.message >>\"
|
|
}" >> /tmp/webhook-data.json
|
|
- run:
|
|
command: |
|
|
curl -i -H "Content-Type: application/json" -X POST -d @/tmp/webhook-data.json $MATTERMOST_RELEASE_WEBHOOK_URL_DESKTOP || echo "NOFICATION FAILED! check logs as this will succeed intentionally"
|
|
|
|
update_image:
|
|
description: "Update base image"
|
|
parameters:
|
|
apt_opts:
|
|
type: string
|
|
default: ""
|
|
steps:
|
|
- run: wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/Release.key | apt-key add -
|
|
- run: apt-get update && apt-get -y install << parameters.apt_opts >>
|
|
- run: npm ci
|
|
|
|
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 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: ELECTRON_DISABLE_SANDBOX=1 xvfb-run npm run test
|
|
- 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"
|
|
|
|
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" }}
|
|
- 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"
|
|
|
|
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" }}
|
|
- 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"
|
|
|
|
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" }}
|
|
- 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"
|
|
|
|
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/*.zip ./dist/win-release
|
|
- run: cp -r release/*.msi ./dist/win-release
|
|
- run: cp -r release/*.exe ./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 ci
|
|
- build:
|
|
os: mac
|
|
path: ./dist/macos-release
|
|
subpath: ./macos-release/
|
|
- run:
|
|
name: Get rename without brew as it might fail
|
|
command: curl -L https://github.com/ap/rename/archive/v1.601.tar.gz --output rename.tgz
|
|
- run:
|
|
name: extract rename
|
|
command: tar -xzf rename.tgz
|
|
- run:
|
|
name: rename arm64 to m1
|
|
command: ./rename-1.601/rename 's/arm64/m1/' release/*
|
|
|
|
store_artifacts:
|
|
executor: wine-chrome
|
|
steps:
|
|
- attach_workspace:
|
|
at: ./dist
|
|
- store_artifacts:
|
|
path: ./dist
|
|
destination: packages
|
|
- run: wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/Release.key | apt-key add -
|
|
- run: apt-get update && apt-get -y install jq
|
|
- run:
|
|
name: "store url links"
|
|
command: |
|
|
echo $(pwd)
|
|
ls .
|
|
curl -H "Circle-Token: $CIRCLE_TOKEN" -H "Accept: application/json" -X GET "https://circleci.com/api/v2/project/github/mattermost/desktop/$CIRCLE_BUILD_NUM/artifacts" | jq -r '.items[].url' >> ./dist/artifactlist.txt
|
|
grep -v ".yml" ./dist/artifactlist.txt | grep -v "\._" > ./templist.txt
|
|
echo "##### :tux: Linux" > ./dist/linklist.txt
|
|
grep "linux" ./templist.txt | awk -F/ '{print "- ["$NF"]("$0")"}' >> ./dist/linklist.txt
|
|
echo "##### :apple_logo: macOS" >> ./dist/linklist.txt
|
|
grep "macos" ./templist.txt | awk -F/ '{print "- ["$NF"]("$0")"}' >> ./dist/linklist.txt
|
|
echo "##### :windows: Windows" >> ./dist/linklist.txt
|
|
grep "win" ./templist.txt | awk -F/ '{print "- ["$NF"]("$0")"}' >> ./dist/linklist.txt
|
|
- persist_to_workspace:
|
|
root: ./dist
|
|
paths:
|
|
- ./linklist.txt
|
|
- ./artifactlist.txt
|
|
|
|
share_to_channel:
|
|
executor: wine-chrome
|
|
steps:
|
|
- attach_workspace:
|
|
at: ./dist
|
|
- run: wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/Release.key | apt-key add -
|
|
- run: apt-get update && apt-get -y install jq
|
|
- run: mkdir -p ./links
|
|
- run: echo "### Nightly builds:\n" > ./links/linklist.txt
|
|
- run:
|
|
name: "Get urls for sharing"
|
|
command: |
|
|
echo "Links for $(date +"%b-%d-%Y")" >> ./links/linklist.txt
|
|
cat ./dist/linklist.txt >> ./links/linklist.txt
|
|
- run:
|
|
command: |
|
|
linklist=$(<./links/linklist.txt);
|
|
echo '{}' | jq "{
|
|
\"username\": \"NightBuilder\",
|
|
\"icon_url\": \"https://upload.wikimedia.org/wikipedia/commons/1/17/Luna_symbol.png\",
|
|
\"text\": \"${linklist}\"
|
|
}" >> /tmp/webhook-data.json
|
|
- run:
|
|
command: |
|
|
curl -i -X POST -H "Content-Type: application/json" -d @/tmp/webhook-data.json $MM_TOKEN || echo "NOFICATION FAILED! check logs as this will succeed intentionally"
|
|
|
|
upload_to_s3:
|
|
executor: aws
|
|
steps:
|
|
- checkout
|
|
- attach_workspace:
|
|
at: ./dist
|
|
- run:
|
|
name: "Don't upload if it's not on a tag"
|
|
command: |
|
|
if [ -z `git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null` ]; then
|
|
circleci-agent step halt
|
|
fi
|
|
- run:
|
|
name: "Setup files for aws-s3"
|
|
command: |
|
|
mkdir -p ./aws-s3-dist
|
|
cp --backup=numbered ./dist/{macos-release,win-release,linux}/* ./aws-s3-dist
|
|
- aws-s3/copy:
|
|
from: ./aws-s3-dist/
|
|
to: s3://releases.mattermost.com/desktop/$(jq -r .version package.json)/
|
|
arguments: --acl public-read --cache-control "no-cache" --recursive
|
|
|
|
upload_to_s3_daily:
|
|
executor: aws
|
|
steps:
|
|
- checkout
|
|
- attach_workspace:
|
|
at: ./dist
|
|
- run:
|
|
name: "Normalize folder names"
|
|
command: |
|
|
mv ./dist/macos-release ./dist/macos
|
|
- aws-s3/copy:
|
|
from: ./dist/
|
|
to: s3://mattermost-desktop-daily-builds/
|
|
arguments: --acl public-read --cache-control "no-cache" --recursive
|
|
|
|
upload_to_github:
|
|
executor: github
|
|
steps:
|
|
- checkout
|
|
- attach_workspace:
|
|
at: ./dist
|
|
- run:
|
|
name: "Don't upload if it's not on a tag"
|
|
command: |
|
|
if [ -z `git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null` ]; then
|
|
circleci-agent step halt
|
|
fi
|
|
- run:
|
|
name: "Setup files for ghr"
|
|
command: |
|
|
mkdir -p ./ghr-dist
|
|
cp --backup=numbered ./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="v${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 \
|
|
v${VERSION} ./ghr-dist
|
|
|
|
begin-notification:
|
|
executor: wine-chrome
|
|
steps:
|
|
- checkout
|
|
- update_image:
|
|
apt_opts: "--no-install-recommends jq"
|
|
- notify:
|
|
message: "Release process for the desktop app has started, it should take about 30 minutes to complete."
|
|
|
|
end-notification:
|
|
executor: wine-chrome
|
|
steps:
|
|
- checkout
|
|
- update_image:
|
|
apt_opts: "--no-install-recommends jq"
|
|
- notify:
|
|
message: "Release process for the desktop app ended, the new release can be found on [GitHub](https://github.com/mattermost/desktop/releases)."
|
|
|
|
|
|
workflows:
|
|
version: 2
|
|
build_and_test:
|
|
jobs:
|
|
- check
|
|
- begin-notification:
|
|
context: desktop-notify
|
|
filters:
|
|
branches:
|
|
only:
|
|
# only for release and release candidates
|
|
# release-XX.YY.ZZ
|
|
# release-XX.YY.ZZ-rc-something
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
- build-linux:
|
|
requires:
|
|
- check
|
|
|
|
- build-win-no-installer:
|
|
requires:
|
|
- check
|
|
filters:
|
|
branches:
|
|
ignore:
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
|
|
- build-mac-no-dmg:
|
|
requires:
|
|
- check
|
|
filters:
|
|
branches:
|
|
ignore:
|
|
- /^release-\d+(\.\d+){1,2}(-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+){1,2}(-rc.*)?/
|
|
|
|
- mac_installer:
|
|
requires:
|
|
- check
|
|
context: codesign-certificates
|
|
filters:
|
|
branches:
|
|
only:
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
|
|
- store_artifacts:
|
|
# for master/PR builds
|
|
requires:
|
|
- build-linux
|
|
- build-win-no-installer
|
|
- build-mac-no-dmg
|
|
filters:
|
|
branches:
|
|
ignore:
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
|
|
- upload_to_s3:
|
|
# for release builds
|
|
requires:
|
|
- msi_installer
|
|
- mac_installer
|
|
- build-linux
|
|
context: mattermost-release-s3
|
|
filters:
|
|
branches:
|
|
only:
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
|
|
- upload_to_github:
|
|
requires:
|
|
- upload_to_s3
|
|
context: matterbuild-github-token
|
|
filters:
|
|
branches:
|
|
only:
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
- end-notification:
|
|
requires:
|
|
- upload_to_github
|
|
context: desktop-notify
|
|
filters:
|
|
branches:
|
|
only:
|
|
# only for release and release candidates
|
|
# release-XX.YY.ZZ
|
|
# release-XX.YY.ZZ-rc-something
|
|
- /^release-\d+(\.\d+){1,2}(-rc.*)?/
|
|
nightly_browser_view:
|
|
when: << pipeline.parameters.run_nightly >>
|
|
jobs:
|
|
- build-linux
|
|
- build-win-no-installer:
|
|
context: electron-installer
|
|
- mac_installer:
|
|
context: codesign-certificates
|
|
- store_artifacts:
|
|
context: desktop_browserview
|
|
# for master/PR builds
|
|
requires:
|
|
- build-linux
|
|
- build-win-no-installer
|
|
- mac_installer
|
|
- upload_to_s3_daily:
|
|
context: mattermost-desktop-daily-s3
|
|
requires:
|
|
- build-linux
|
|
- build-win-no-installer
|
|
- mac_installer
|
|
- share_to_channel:
|
|
context: desktop_browserview
|
|
requires:
|
|
- store_artifacts
|
|
|