2020-11-04 01:22:11 +00:00
|
|
|
# This file is a template, and might need editing before it works on your project.
|
|
|
|
# see https://docs.gitlab.com/ee/ci/yaml/README.html for all available options
|
|
|
|
|
2020-11-04 01:40:43 +00:00
|
|
|
variables:
|
|
|
|
DEFAULT_IMAGE: debian:stable
|
2020-11-11 00:34:09 +00:00
|
|
|
APT_CACHE_DIR: $CI_PROJECT_DIR/.cache/apt
|
2020-11-11 17:38:42 +00:00
|
|
|
NPM_CONFIG_CACHE: $CI_PROJECT_DIR/.cache/npm
|
2020-11-20 23:23:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# We have code in here for releasing on both GS and S3, control it through variables
|
|
|
|
# on GitLab, do not change it in this file.
|
|
|
|
#
|
2020-11-11 18:00:15 +00:00
|
|
|
GCLOUD_SERVICE_ACCOUNT: /dev/null
|
2020-11-12 06:40:44 +00:00
|
|
|
GCLOUD_RELEASE_DEPLOY_PATH: gs://download.gridtracker.org/release/$CI_COMMIT_TAG
|
|
|
|
GCLOUD_TESTING_DEPLOY_PATH: gs://download.gridtracker.org/testing/$CI_COMMIT_TAG
|
2020-11-20 23:23:04 +00:00
|
|
|
AWS_ACCESS_KEY_ID: ""
|
|
|
|
AWS_SECRET_ACCESS_KEY: ""
|
|
|
|
AWS_DEFAULT_REGION: ""
|
|
|
|
AWS_RELEASE_DEPLOY_PATH: s3://download.gridtracker.org/release/$CI_COMMIT_TAG
|
|
|
|
AWS_TESTING_DEPLOY_PATH: s3://download.gridtracker.org/testing/$CI_COMMIT_TAG
|
2020-11-12 06:40:44 +00:00
|
|
|
|
2020-11-20 23:23:04 +00:00
|
|
|
# nothing in this file ill be allowed to run automatically except for:
|
2020-11-12 06:40:44 +00:00
|
|
|
# 1. merge requests
|
|
|
|
# 2. manual tagging
|
|
|
|
# 3. committing to the default branch
|
|
|
|
include:
|
|
|
|
- template: "Workflows/MergeRequest-Pipelines.gitlab-ci.yml"
|
2020-11-10 22:54:15 +00:00
|
|
|
|
2020-11-11 05:57:38 +00:00
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
- test
|
2020-11-11 18:00:15 +00:00
|
|
|
- package
|
2020-11-11 05:57:38 +00:00
|
|
|
- deploy
|
|
|
|
|
2020-11-04 01:40:43 +00:00
|
|
|
default:
|
|
|
|
image: ${DEFAULT_IMAGE}
|
|
|
|
interruptible: true
|
2020-11-04 01:22:11 +00:00
|
|
|
|
2020-11-12 06:40:44 +00:00
|
|
|
# just do a quick syntax check job, we don't need to "build" anything here other than the
|
|
|
|
# outer dev environment for gridtracker
|
2020-11-11 18:00:15 +00:00
|
|
|
npm_test:
|
|
|
|
stage: test
|
|
|
|
image: node:latest
|
|
|
|
script:
|
|
|
|
- npm install
|
|
|
|
- npm test
|
|
|
|
|
|
|
|
# test2:
|
|
|
|
# stage: test
|
|
|
|
# script:
|
|
|
|
# - echo "Do another parallel test here"
|
|
|
|
# - echo "For example run a lint test"
|
|
|
|
|
|
|
|
|
2020-11-12 06:40:44 +00:00
|
|
|
# package binaries and create build artifacts that may be used in later stages
|
2020-11-11 00:34:09 +00:00
|
|
|
|
2020-11-11 18:00:15 +00:00
|
|
|
packaging:
|
|
|
|
stage: package
|
|
|
|
rules:
|
2020-11-12 06:40:44 +00:00
|
|
|
# only do this with a manual tag starting with v or test_
|
2020-11-11 18:00:15 +00:00
|
|
|
- if: '$CI_COMMIT_TAG =~ /^(v|test_).*/'
|
|
|
|
artifacts:
|
|
|
|
paths:
|
2020-11-11 18:35:41 +00:00
|
|
|
- build/
|
2020-11-11 18:00:15 +00:00
|
|
|
name: '$CI_COMMIT_REF_SLUG'
|
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .cache/
|
|
|
|
- node_modules/
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- package.json
|
|
|
|
- package.nw/package.json
|
2020-11-04 01:22:11 +00:00
|
|
|
script:
|
2020-11-11 18:00:15 +00:00
|
|
|
- mkdir -p $APT_CACHE_DIR $NPM_CONFIG_CACHE
|
2020-11-17 20:08:56 +00:00
|
|
|
- mkdir -p build/debian build/rpm
|
2020-11-11 18:00:15 +00:00
|
|
|
- dpkg --add-architecture i386
|
|
|
|
- apt-get -qq update
|
|
|
|
- apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y npm wine wine32
|
2020-11-18 00:41:45 +00:00
|
|
|
- apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y build-essential devscripts
|
|
|
|
- apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y rpm
|
|
|
|
- apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" build-dep .
|
2020-11-18 00:46:13 +00:00
|
|
|
- test `node version.js` = `dpkg-parsechangelog -S version` || (echo "package.nw/package.json and debian/changelog version mismatch"; exit 1)
|
2020-11-17 20:08:56 +00:00
|
|
|
- echo "Building native packages"
|
2020-11-11 18:00:15 +00:00
|
|
|
- npm install --prefer-offline
|
|
|
|
- npm run dist
|
2021-03-10 01:17:19 +00:00
|
|
|
- for dir in dist/*-linux-* ; do if [ -d $dir ] ; then tar -C dist -czf ${dir}.tar.gz `basename $dir` ; fi ; done
|
2021-03-10 01:57:33 +00:00
|
|
|
- (cd dist ; mv *.exe *-mac-x64.zip *.tar.gz ../build)
|
2020-11-17 20:08:56 +00:00
|
|
|
- echo "Building Debian packages"
|
2020-11-11 18:00:15 +00:00
|
|
|
- dpkg-buildpackage -uc -us
|
|
|
|
- mv ../*.{deb,dsc,buildinfo,tar.xz,changes} build/debian/
|
2020-11-17 20:08:56 +00:00
|
|
|
- echo "Building RPM packages"
|
2021-03-10 02:00:04 +00:00
|
|
|
- cp GridTracker-*.x86.tar.gz $HOME/rpmbbuild/SOURCES/
|
|
|
|
- cp GridTracker-*.x64.tar.gz $HOME/rpmbuild/SOURCES/
|
2021-03-10 01:06:48 +00:00
|
|
|
- rpmbuild -D "version `node ./version.js`" --build-in-place -bb gridtracker.i386.spec
|
|
|
|
- rpmbuild -D "version `node ./version.js`" --build-in-place -bb gridtracker.x86_64.spec
|
|
|
|
- mv $HOME/rpmbuild/RPMS/i386/gridtracker-*.i386.rpm build/rpm
|
|
|
|
- mv $HOME/rpmbuild/RPMS/x86_64/gridtracker-*.x86_64.prm build/rpm
|
2020-11-04 20:29:13 +00:00
|
|
|
|
2020-11-12 06:40:44 +00:00
|
|
|
# copy the assets over to our distribution storage (testing, tag = test_.*)
|
2020-11-20 23:23:04 +00:00
|
|
|
gs_upload_testing:
|
2020-11-11 18:00:15 +00:00
|
|
|
stage: deploy
|
|
|
|
image: google/cloud-sdk:alpine
|
|
|
|
rules:
|
2020-11-20 23:23:04 +00:00
|
|
|
- if: '$CI_COMMIT_TAG =~ /^(test_).*/ && $GCLOUD_SERVICE_ACCOUNT != "/dev/null"'
|
2020-11-11 18:00:15 +00:00
|
|
|
script:
|
|
|
|
- gcloud auth activate-service-account --key-file $GCLOUD_SERVICE_ACCOUNT
|
2020-11-12 06:40:44 +00:00
|
|
|
- cd build; gsutil -m rsync -r . $GCLOUD_TESTING_DEPLOY_PATH
|
|
|
|
|
|
|
|
# copy the assets over to our distribution storage (full release, tag = v.*)
|
2020-11-20 23:23:04 +00:00
|
|
|
gs_upload_release:
|
2020-11-12 06:40:44 +00:00
|
|
|
stage: deploy
|
|
|
|
image: google/cloud-sdk:alpine
|
|
|
|
rules:
|
2020-11-20 23:23:04 +00:00
|
|
|
- if: '$CI_COMMIT_TAG =~ /^(v).*/ && $GCLOUD_SERVICE_ACCOUNT != "/dev/null"'
|
2020-11-12 06:40:44 +00:00
|
|
|
script:
|
|
|
|
- gcloud auth activate-service-account --key-file $GCLOUD_SERVICE_ACCOUNT
|
|
|
|
- cd build; gsutil -m rsync -r . $GCLOUD_RELEASE_DEPLOY_PATH
|
2020-11-11 18:00:15 +00:00
|
|
|
|
2020-11-20 23:23:04 +00:00
|
|
|
# copy the assets over to our distribution storage (testing, tag = test_.*)
|
|
|
|
s3_upload_testing:
|
|
|
|
stage: deploy
|
|
|
|
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG =~ /^(test_).*/ && $AWS_ACCESS_KEY_ID != ""'
|
|
|
|
script:
|
|
|
|
- cd build; aws s3 sync . $AWS_TESTING_DEPLOY_PATH
|
|
|
|
|
|
|
|
# copy the assets over to our distribution storage (full release, tag = v.*)
|
|
|
|
s3_upload_release:
|
|
|
|
stage: deploy
|
|
|
|
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG =~ /^(v).*/ && $AWS_ACCESS_KEY_ID != ""'
|
|
|
|
script:
|
|
|
|
- cd build; aws s3 sync . $AWS_RELEASE_DEPLOY_PATH
|
|
|
|
|
2020-11-11 18:00:15 +00:00
|
|
|
# this only creates a "source code release" -- gitlab doesn't specify binaries
|
|
|
|
# except as links to external storage, which is suboptimal for now
|
|
|
|
source_release:
|
|
|
|
stage: deploy
|
|
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
|
|
rules:
|
2020-11-12 06:40:44 +00:00
|
|
|
- if: '$CI_COMMIT_TAG =~ /^(v).*/'
|
2020-11-11 18:00:15 +00:00
|
|
|
release:
|
2020-11-18 22:52:52 +00:00
|
|
|
tag_name: $CI_COMMIT_TAG
|
|
|
|
name: GridTracker $CI_COMMIT_TAG
|
|
|
|
description: GridTracker release $CI_COMMIT_TAG
|
2020-11-11 18:00:15 +00:00
|
|
|
ref: '$CI_COMMIT_SHA'
|
2020-11-18 22:52:52 +00:00
|
|
|
assets:
|
|
|
|
links:
|
|
|
|
- name: Binary images for $CI_COMMIT_TAG
|
|
|
|
url: https://download.gridtracker.org/release/$CI_COMMIT_TAG/
|
2020-11-12 06:40:44 +00:00
|
|
|
script:
|
|
|
|
- echo 'Release for $CI_COMMIT_TAG'
|