gridtracker/.gitlab-ci.yml

129 wiersze
4.4 KiB
YAML

# 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
variables:
DEFAULT_IMAGE: debian:stable
APT_CACHE_DIR: $CI_PROJECT_DIR/.cache/apt
NPM_CONFIG_CACHE: $CI_PROJECT_DIR/.cache/npm
GCLOUD_SERVICE_ACCOUNT: /dev/null
GCLOUD_RELEASE_DEPLOY_PATH: gs://download.gridtracker.org/release/$CI_COMMIT_TAG
GCLOUD_TESTING_DEPLOY_PATH: gs://download.gridtracker.org/testing/$CI_COMMIT_TAG
# nothing in this file should be allowed to run automatically except for:
# 1. merge requests
# 2. manual tagging
# 3. committing to the default branch
include:
- template: "Workflows/MergeRequest-Pipelines.gitlab-ci.yml"
stages:
- build
- test
- package
- deploy
default:
image: ${DEFAULT_IMAGE}
interruptible: true
# just do a quick syntax check job, we don't need to "build" anything here other than the
# outer dev environment for gridtracker
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"
# package binaries and create build artifacts that may be used in later stages
packaging:
stage: package
rules:
# only do this with a manual tag starting with v or test_
- if: '$CI_COMMIT_TAG =~ /^(v|test_).*/'
artifacts:
paths:
- build/
name: '$CI_COMMIT_REF_SLUG'
cache:
paths:
- .cache/
- node_modules/
key:
files:
- package.json
- package.nw/package.json
script:
- mkdir -p $APT_CACHE_DIR $NPM_CONFIG_CACHE
- mkdir -p build/debian build/rpm
- dpkg --add-architecture i386
- apt-get -qq update
- apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y npm wine wine32
- 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 .
- test `node version.js` = `dpkg-parsechangelog -S version` || (echo "package.nw/package.json and debian/changelog version mismatch"; exit 1)
- echo "Building native packages"
- npm install --prefer-offline
- npm run dist
- (cd dist ; mv *.zip *.exe *.7z *.json ../build)
- echo "Building Debian packages"
- dpkg-buildpackage -uc -us
- mv ../*.{deb,dsc,buildinfo,tar.xz,changes} build/debian/
- echo "Building RPM packages"
- rpmbuild -D "version `node ./version.js`" --build-in-place --buildroot `pwd`/buildroot -bb --target noarch gridtracker.spec
- mv buildroot/RPMS/noarch/gridtracker-*.noarch.rpm build/rpm
# copy the assets over to our distribution storage (testing, tag = test_.*)
upload_testing:
stage: deploy
image: google/cloud-sdk:alpine
needs:
- job: packaging
rules:
- if: '$CI_COMMIT_TAG =~ /^(test_).*/'
script:
- gcloud auth activate-service-account --key-file $GCLOUD_SERVICE_ACCOUNT
- cd build; gsutil -m rsync -r . $GCLOUD_TESTING_DEPLOY_PATH
# copy the assets over to our distribution storage (full release, tag = v.*)
upload_release:
stage: deploy
image: google/cloud-sdk:alpine
needs:
- job: packaging
rules:
- if: '$CI_COMMIT_TAG =~ /^(v).*/'
script:
- gcloud auth activate-service-account --key-file $GCLOUD_SERVICE_ACCOUNT
- cd build; gsutil -m rsync -r . $GCLOUD_RELEASE_DEPLOY_PATH
# 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:
- if: '$CI_COMMIT_TAG =~ /^(v).*/'
release:
tag_name: '$CI_COMMIT_TAG'
name: 'GridTracker $CI_COMMIT_TAG'
description: 'GridTracker source archive for $CI_COMMIT_TAG'
ref: '$CI_COMMIT_SHA'
script:
- echo 'Release for $CI_COMMIT_TAG'
# (unused yet, need to decide if we do this manually or not)
# release-cli create --name "$GridTracker $CI_COMMIT_TAG" \
# --tag-name "$CI_COMMIT_TAG" \
# --assets-link "{\"name\":\"${DARWIN_AMD64_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${DARWIN_AMD64_BINARY}\"}" \
# --assets-link "{\"name\":\"${LINUX_AMD64_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}\"}"