app/.gitlab-ci.yml

95 lines
2.1 KiB
YAML

stages:
- test
- ui
- build
- build-docker
- deploy
- release
test:
image: "rust:slim-buster"
stage: test
script:
- mkdir dist
- touch dist/index.html
- apt-get update
- apt-get -y install libssl-dev pkg-config
- cargo test
build-ui:
stage: ui
image: node:16.13-slim
script:
- apt-get update
- apt-get -y install libssl-dev
- npm install
- npm run build
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
artifacts:
paths:
- dist/
build-bin:
dependencies:
- build-ui
image: "rust:slim-buster"
stage: build
tags:
- linux
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- apt-get update
- apt-get -y install libssl-dev pkg-config
- cargo build --release
- cd target/release
- tar -czf ../../vade-linux-x64.tar.gz vade
- cd ../../
artifacts:
paths:
- target/release/vade
- vade-linux-x64.tar.gz
build-docker:
dependencies:
- build-bin
stage: build-docker
image: docker:latest
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY/vade/vade-mecum .
- docker push $CI_REGISTRY/vade/vade-mecum
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
deploy-binaries:
dependencies:
- build-bin
image: curlimages/curl:latest
stage: deploy
rules:
- if: $CI_COMMIT_TAG
script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./vade-linux-x64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/bin/$CI_COMMIT_TAG/vade-linux-x64-$CI_COMMIT_TAG.tar.gz"'
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- echo "running release_job"
release:
name: 'Release v$CI_COMMIT_TAG'
description: 'Version $CI_COMMIT_TAG'
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
assets:
links:
- name: 'vade-linux-x64-$CI_COMMIT_TAG.tar.gz'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/linux-bin/$CI_COMMIT_TAG/vade-linux-x64-$CI_COMMIT_TAG.tar.gz'