Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • EOLE/infra/ci-tools
  • daniel.dehennin/ci-tools
2 results
Show changes
Commits on Source (128)
Showing
with 2483 additions and 339 deletions
extends:
- '@commitlint/config-conventional'
rules:
body-max-line-length: [2, 'always', 120]
footer-max-line-length: [2, 'always', 120]
header-max-length: [2, 'always', 72]
......@@ -4,9 +4,9 @@
include:
- local: templates/Rules.yaml
- local: templates/Runners/eole-docker.yaml
- local: templates/Lint/Commitlint.yaml
- local: templates/Git.yaml
- local: templates/Docker.yaml
- local: templates/Release/Semantic-release.yaml
- local: templates/Semantic-release.yaml
stages:
- lint
......@@ -16,7 +16,15 @@ stages:
.docker-matrix:
parallel:
matrix:
- IMAGE_NAME: [commitlint, semantic-release-gitlab]
- IMAGE_NAME:
- commitlint
- helm
- semantic-release-gitlab
###############################################################################
# `lint` stage: `commitlint`
###############################################################################
commitlint: {extends: '.git:commitlint'}
###############################################################################
# `build` stage: `*-docker-build`
......@@ -25,16 +33,28 @@ stages:
build-docker:
extends:
- .docker-matrix
- .build-docker-image
- .docker:image:build
###############################################################################
# `release` stage: `semantic-release`, `*-docker-tag`
# `release` stage: `new-release`, `tag *`
###############################################################################
# Create the release versions on `$STABLE_BRANCH`
new release: {extends: '.semantic-release:stable'}
# Suffix all jobs to avoid conflict with other jobs names
.tag-docker:
extends:
- .docker-matrix
- .tag-docker-image
- .docker:image:tag
## tag contribution branches with a more stable name than `git-${CI_COMMIT_SHORT_SHA}`
tag contrib branch:
extends:
- .tag-docker
- .on-branches
variables:
# `feature/foo-bar_quux` → `feature-foo-bar-quux`
IMAGE_TAG: $CI_COMMIT_REF_SLUG
## dev images
tag dev:
......
// Build the configuration depending of the environnement
// When using prerelease branches, we don't want changelog to be generated
// See https://github.com/semantic-release/changelog/issues/51#issuecomment-682609394
// Gitlab reference name
const branch = process.env.CI_COMMIT_REF_NAME;
const gitAssets = [];
// Configure your branches names
const stableBranch = 'stable';
// Assign a branch name to produce a `beta` prerelease tag
const betaBranch = undefined;
// Assign a branch name to produce a `alpha` prerelease tag
const alphaBranch = undefined;
// Assign a branch name to produce a `dev` prerelease tag
const devBranch = undefined;
// Configure semantic-release plugins
const breakingKeywords = [
"BREAKING CHANGE",
"BREAKING-CHANGE",
"BREAKING CHANGES",
"BREAKING-CHANGES"
];
const changelogFile = 'docs/CHANGELOG.md';
// const chartDir = './chart';
// Configure `conventionalcommits`
// See:
// - https://github.com/conventional-changelog/conventional-changelog/issues/838
// - https://github.com/conventional-changelog/conventional-changelog/issues/317
// - https://github.com/conventional-changelog/conventional-changelog/pull/421
const commitTypes = [
{ type: "feat", section: "Features", hidden: false },
{ type: "fix", section: "Bug Fixes", hidden: false },
{ type: "docs", section: "Documentation", hidden: false },
{ type: "test", section: "Tests", hidden: false },
{ type: "perf", section: "Performance Improvements", hidden: false },
{ type: "revert", section: "Reverts", hidden: false },
{ type: "refactor", section: "Code Refactoring", hidden: false },
{ type: "style", section: "Styles", hidden: false },
{ type: "build", section: "Build System", hidden: false },
{ type: "ci", section: "Continuous Integration", hidden: false },
{ type: "chore", section: "Maintenance", hidden: true },
];
// Group commit by type and sort the sections according to `commitTypes` sorting
const commitGroups = commitTypes.map((e) => { return e.section; });
function commitGroupsSortFn(a, b) {
return commitGroups.indexOf(a.title) - commitGroups.indexOf(b.title);
};
const releaseRules = [
{ breaking: true, release: 'major' },
// { type: 'build', release: 'patch'},
// { type: 'chore', release: 'patch'},
// { type: 'ci', release: 'patch'},
{ type: 'docs', release: 'patch' },
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
{ type: 'perf', release: 'patch' },
{ type: 'refactor', release: 'patch' },
{ type: 'revert', release: 'patch' },
{ type: 'style', release: 'patch' },
{ type: 'test', release: 'patch' },
];
const semanticBranches = [stableBranch];
if (betaBranch) {
semanticBranches.push({
name: betaBranch,
prerelease: true
});
}
if (alphaBranch) {
semanticBranches.push({
name: alphaBranch,
prerelease: true
});
}
if (devBranch) {
semanticBranches.push({
name: devBranch,
prerelease: true
});
}
const config = {
branches: semanticBranches,
/* eslint no-template-curly-in-string: "off" */
tagFormat: 'release/${version}',
plugins: [
[
'@semantic-release/commit-analyzer',
{
preset: 'conventionalcommits',
parserOpts:
{
noteKeywords: breakingKeywords,
},
releaseRules: releaseRules,
presetConfig:
{
types: commitTypes,
},
},
],
[
'@semantic-release/release-notes-generator',
{
preset: 'conventionalcommits',
parserOpts:
{
noteKeywords: breakingKeywords,
},
writerOpts:
{
commitGroupsSort: commitGroupsSortFn,
},
presetConfig:
{
types: commitTypes,
commitUrlFormat: '{{host}}/{{owner}}/{{repository}}/-/commit/{{hash}}',
compareUrlFormat: '{{host}}/{{owner}}/{{repository}}/-/compare/{{previousTag}}...{{currentTag}}',
issueUrlFormat: '{{host}}/{{owner}}/{{repository}}/-/issues/{{id}}',
},
},
],
],
};
if (
!Array.isArray(config.branches) ||
config.branches.some((it) => it === branch || (it.name === branch && !it.prerelease))
) {
// Generate changelog for release branch
config.plugins.push([
'@semantic-release/changelog',
{
changelogFile: changelogFile,
changelogTitle: '# Changelog',
},
]);
gitAssets.push(changelogFile);
}
// // We need to update package*.json
// // Make sure to modify pkgRoot and gitAssets lines for your needs
// config.plugins.push(
// [
// '@semantic-release/npm',
// {
// npmPublish: false,
// tarballDir: 'dist',
// pkgRoot: 'app',
// },
// ]
// );
// gitAssets.push('app/package*.json');
// // Python: update the version string in the module file
// // Use sed to change the version string in a file
// const sedVersionFile = './src/version.py';
// var sedVersionCmd = "sed -i -e 's,^\\(.*__version__\\).*,\\1 = \"${nextRelease.version}\",' ";
// config.plugins.push(
// [
// '@semantic-release/exec',
// {
// prepareCmd: sedVersionCmd.concat(sedVersionFile),
// },
// ]
// );
// gitAssets.push(sedVersionFile);
// // Update Helm chart version
// config.plugins.push(
// [
// 'semantic-release-helm3',
// {
// chartPath: chartDir,
// onlyUpdateVersion: true,
// },
// ]
// );
// gitAssets.push(chartDir.concat('/Chart.yaml'));
// Commit changes and create release on Gitlab
config.plugins.push(
[
'@semantic-release/git',
{
assets: gitAssets,
message: 'chore(release): ${nextRelease.version}\n\n${nextRelease.notes}',
},
],
'@semantic-release/gitlab',
);
module.exports = config;
......@@ -2,8 +2,8 @@ FROM node:current-alpine
LABEL maintainer="eole@ac-dijon.fr"
ARG COMMITLINT_VERSION=13
ARG COMMITLINT_CONFIG_CONVENTIONAL_VERSION=13
ARG COMMITLINT_VERSION=16
ARG COMMITLINT_CONFIG_CONVENTIONAL_VERSION=16
RUN apk add --no-cache git \
ca-certificates
......
FROM alpine:latest as INSTALLER
LABEL maintainer="eole@ac-dijon.fr"
RUN apk add --no-cache \
ca-certificates \
curl \
git \
openssl
RUN curl -o get-helm-3 https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
RUN sh ./get-helm-3
RUN helm plugin install https://github.com/chartmuseum/helm-push
FROM alpine:latest
LABEL maintainer="eole@ac-dijon.fr"
RUN apk add --no-cache git
COPY --from=INSTALLER /usr/local/bin/helm /usr/local/bin/helm
COPY --from=INSTALLER /root/.local/share/helm/ /root/.local/share/helm
......@@ -2,17 +2,23 @@ FROM node:current-alpine
LABEL maintainer="eole@ac-dijon.fr"
ARG SEMANTIC_RELEASE_VERSION=18
ARG SEMAINTIC_GITLAB_VERSION=7
ARG SEMANTIC_RELEASE_VERSION=19
ARG SEMAINTIC_GITLAB_VERSION=8
ARG SEMAINTIC_CHANGELOG_VERSION=6
ARG CONVENTIONALCOMMITS_VERSION=4
ARG SEMAINTIC_EXEC_VERSION=6
ARG SEMAINTIC_GIT_VERSION=10
ARG SEMANTIC_NPM_VERSION=9
ARG SEMANTIC_HELM_VERSION=2
RUN apk add --no-cache git \
ca-certificates
ca-certificates
RUN npm install -g semantic-release@${SEMAINTIC_RELEASE_VERSION} \
@semantic-release/gitlab@${SEMAINTIC_GITLAB_VERSION} \
@semantic-release/changelog@${SEMAINTIC_CHANGELOG_VERSION} \
@semantic-release/exec@${SEMAINTIC_EXEC_VERSION} \
@semantic-release/git@${SEMAINTIC_GIT_VERSION}
@semantic-release/git@${SEMAINTIC_GIT_VERSION} \
@semantic-release/npm@${SEMAINTIC_NPM_VERSION} \
conventional-changelog-conventionalcommits@${CONVENTIONALCOMMITS_VERSION} \
semantic-release-helm3@${SEMANTIC_HELM_VERSION}
# CI tools
# Tools for the Gitlab CI
Tools for the Gitlab CI
This project provides several YAML files to be
[included](https://docs.gitlab.com/ee/ci/yaml/#include) in your
project [.gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/) file.
[[_TOC_]]
## Features
The CI tools:
- supports up to 3 branches in a release cycles
- provides YAML templates to
- [validate commit message formatting](docs/GETTING-STARTED.md#validate-commit-messages)
- [build and tag docker images](docs/GETTING-STARTED.md#build-and-tag-docker-images)
- [publish releases automatically on push to `$STABLE_BRANCH`](docs/GETTING-STARTED.md#generate-release-with-semantic-version-scheme)
```mermaid
graph LR
%% User working branch
Branch([CONTRIB BRANCH])
BranchCI{{CI}}
BranchCommitLint(commitlint)
BranchDockerImage((image))
BranchDockerTag>docker:git-$CI_COMMIT_SHORT_SHA]
%% Project `dev` branch
Dev([DEV])
DevCI{{CI}}
DevCommitLint(commitlint)
DevDockerImage((image))
DevDockerTag>docker:dev]
%% Project `testing` branch for prerelease
Testing([TESTING])
TestingCI{{CI}}
TestingCommitLint(commitlint)
TestingDockerImage((image))
TestingDockerTag>docker:testing]
%% Project `stable` branch
Stable([STABLE])
StableCI{{CI}}
%% Project `release` tag
Release>release/x.y.z]
ReleaseCI{{CI}}
ReleaseDockerTag{{docker:x.y.z}}
MajorDockerTag{{docker:x}}
MinorDockerTag{{docker:x.y}}
StableDockerTag{{docker:stable}}
LatestDockerTag{{docker:latest}}
Branch -->|push| BranchCI
BranchCI -->|lint| BranchCommitLint
BranchCI -->|build| BranchDockerImage
BranchCI -->|release| BranchDockerTag
BranchDockerTag -.- BranchDockerImage
Branch -->|merge| Dev
Dev -->|push| DevCI
DevCI -->|lint| DevCommitLint
DevCI -->|build| DevDockerImage
DevCI -->|release| DevDockerTag
DevDockerTag -.- DevDockerImage
Dev -->|merge| Testing
Testing -->|push| TestingCI
TestingCI -->|lint| TestingCommitLint
TestingCI -->|build| TestingDockerImage
TestingCI -->|release| TestingDockerTag
TestingDockerTag -.- TestingDockerImage
Testing -->|merge| Stable
Stable -->|push| StableCI
StableCI -->|release| Release
Release -->|push| ReleaseCI
ReleaseCI -->|release| ReleaseDockerTag
ReleaseCI -->|release| MajorDockerTag
ReleaseCI -->|release| MinorDockerTag
ReleaseCI -->|release| StableDockerTag
ReleaseCI -->|release| LatestDockerTag
```
## Use the ci-tools to setup a new CI
There is a dedicated [documentation to start using the `ci-tools`
templates](docs/GETTING-STARTED.md) in your project.
## Contributing to this project
......
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [2, 'always', 120],
'footer-max-line-length': [2, 'always', 120],
'header-max-length': [2, 'always', 72],
},
};
# Changelog
# [1.1.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/compare/release/1.0.0...release/1.1.0) (2021-11-30)
## [1.12.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.11.1...release/1.12.0) (2022-07-05)
### Features
* **semantic-release:** use the image build by CI itself ([ba0d024](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/ba0d02416182df2e8ef66d1f4613c95d7ff841ec))
* **maven:** copy package to remote repository with `.maven:deploy` ([b72b0a8](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b72b0a821fd32c065fc7cf60b3a344003c46b373))
* **maven:** ensure quality criteria are met with `.maven:verify` ([a46a236](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/a46a23683add58623bae5c6ce1b4e8367705923f))
* **maven:** validate the project with `.maven:validate` ([92d822d](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/92d822d48d6bac266f4ffaa891217280d36b68ba))
### Bug Fixes
* **maven:** define `SRC_DIR` variable ([8d8a6af](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/8d8a6af8249923dc027c37cf53c7dec9c6f0dedb))
### [1.11.1](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.11.0...release/1.11.1) (2022-06-28)
### Bug Fixes
* **.git:commitlint:** workaround loading project configuration ([fde1fc0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/fde1fc07df5358531df6bfb99ae9aabd279cb490))
## [1.11.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.10.0...release/1.11.0) (2022-06-23)
### Features
* **.git:commitlint:** skip no branch or semantic-release commit ([3a855ab](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/3a855ab00db2a0a8022ad14e4c53e02dc93bd01c))
* **helm:** build the helm package ([115a62a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/115a62a808a91f9ad2b1aa74775786c3d693b330))
* **helm:** publish the helm package ([98f3a6e](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/98f3a6e473d2fb49d3335deaee99812b2d234103))
* **helm:** verify helm formatting with `.helm:lint` job template ([7e1ccbd](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/7e1ccbd30f8f53fa29bfc574159e52999803f5e7))
* **semantic-release:** don't enforce configuration on job rules ([1a1a9ca](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/1a1a9cac043b2458f9811c76bdc0e15784904eec))
* **semantic-release:** update version of Helm charts ([f776b12](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/f776b127787ba40bbb831a621f3fc76015889aad))
### Bug Fixes
* **helm:** rename jobs to their used helm command ([7d6886c](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/7d6886c5c9edd79f310cb7ff6900c0837079c411))
### Code Refactoring
* **semantic-release:** move rules in main configuration file ([2ba784d](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/2ba784d805aefc92d60559330b78f5edf9c986e2))
### Documentation
* **getting-started:** update `semantic-release` configuration steps ([b6d5bc5](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b6d5bc56c08e2526186f32bf5daf7a8b42bb087b))
### Continuous Integration
* **build:** new docker image with required helm tools ([e620568](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/e62056859609fb3f18c718cc06f9349299b97ca2))
## [1.10.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.9.1...release/1.10.0) (2022-03-22)
### Features
* **semantic-release:** comment merge requests and issues in release ([bc387d4](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/bc387d41916a0f2a299022a40570ed8967d3aa3a))
### [1.9.1](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.9.0...release/1.9.1) (2022-03-22)
### Bug Fixes
* **python:** backquotes in shell strings try to execute commands ([e9cde63](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/e9cde63792ee1e0081e7e6b744a0ac64c8313154))
## [1.9.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.8.0...release/1.9.0) (2022-03-21)
### Features
* **python:** use `build` module to support PEP517 package building ([a45db53](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/a45db53855b9827309e864df891acbc8c7a7dedb))
## [1.8.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.7.0...release/1.8.0) (2022-03-18)
### Features
* **python:** build source distribution package ([1ee7498](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/1ee7498b836bc68166d46f92b1624958a61382b9))
* **python:** build wheel package ([6b6a59f](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/6b6a59f217dce7471dfa77611a13495b78c0cbc0))
* **python:** check code formatting using `black` ([4c9f045](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/4c9f0456851edf1d4303f833c61848ac99010ab5))
* **python:** upload python package files with `twine` ([8a1d9d4](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/8a1d9d4cfb21b4fbe3fee2a26fc8f786f933e2af))
## [1.7.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.6.0...release/1.7.0) (2022-03-15)
### Features
* **semantic-release:** switch to `conventionalcommits` changelog ([07950c4](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/07950c4c09e7f919d8597e95c51b91315fdcb2e1))
# [1.6.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.5.0...release/1.6.0) (2022-03-15)
### Features
* **git:** new `.git:merge-to` job template to merge a reference ([f8501fc](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/f8501fc7e3301e9f30718faef2cdf9021cf80c62))
# [1.5.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.4.0...release/1.5.0) (2022-02-16)
### Documentation
* **getting-started:** generate prerelease version for `testing` ([733fb66](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/733fb661a574ab4de834c062796bc8376f8fe35f))
### Features
* **commitlint:** update `commitlint` to version 16 ([d003342](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/d003342a376965f7dbfa7c6baf1edc124912ffc2))
* **docker:** tag docker image of contributor branches ([1ddb17e](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/1ddb17e4589e44055dbf7213189813d68078cc15))
* **semantic-release:** new job templates for prerelease ([879854f](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/879854fe5ac7e6d6af508a42a32f79fa9173044d))
* **semantic-release:** update to version `19` ([92aceec](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/92aceec996568a67eef5b19221ec0be4ea1277dd))
# [1.4.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.3.0...release/1.4.0) (2022-01-24)
### Features
* **rules:** support prerelease tags for `semantic-release` ([0ec996a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/0ec996ac0072235cdca3fc51c2a1eb611d3b1665))
* **semantic-release/config:** easier declaration of branches ([c7acd28](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/c7acd28195c7effa730ff20e2bc6de1d2f6991fc))
* **semantic-release:** new rules for prerelease ([b2752bd](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b2752bd900d23c554adf07b1feb54597f0dbd968))
# [1.3.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.2.1...release/1.3.0) (2022-01-11)
### Bug Fixes
* **semantic-release:** the branch must be `stable` ([4b9152d](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/4b9152dcae29a8cd792de452041d47da6bf6807c))
### Code Refactoring
* **commitlint:** the upstream extra repository is useless ([cdff4ab](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/cdff4abd8af608b8ab31398c0a6703a50eae0e08))
### Documentation
* **commitlint:** describe usage of the commitlint job ([8b3749f](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/8b3749f044227c390e15480c63f125c24e99767a))
* **getting-started:** quick setup and detailed explanations ([007aa21](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/007aa2195252d8140d8ecd4438f231a973aa30e9))
* **readme:** demonstrate a possible release cycle ([8d02a0c](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/8d02a0cf712cb590cfc3a65d7231a9157bcbbbb6))
### Features
* **commitlint:** users can configure image with `$COMMITLINT_IMAGE` ([bc7f19c](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/bc7f19c3be02a00e03a39ffe31b4fecbd5454964))
* **commitlint:** users can configure the base branch ([612dc3e](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/612dc3ea47080f3213cc6610ec321b4c57fa8e72))
* **docker:** .build-docker-image must accept kaniko arguments ([bd5c77e](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/bd5c77eabbc03fec73b9405ef392197a5029ae29))
* **semantic-release:** don't build changelog on prerelease branches ([5a02f5d](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/5a02f5d23aca195cb18f2e0d865eaf4c13b7351f))
* **semantic-release:** manage python projects releases ([9794bcb](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/9794bcb0b7d427af10e99a65723456953f575182))
### Styles
* **js:** js configuration files do not pass eslint ([5874dca](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/5874dca35effe04f82ff848918706a15012dcf73))
## [1.2.1](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.2.0...release/1.2.1) (2021-12-09)
### Code Refactoring
* **rules:** permit to combine individual rules ([075712a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/075712a9d7e7d9cac8731debb0312a092bcefbb2)), closes [#3](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/issues/3)
# [1.2.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.1.0...release/1.2.0) (2021-12-06)
### Features
* **rules:** we want to skip pipelines on more keywords ([0a24edb](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/0a24edbeb188efe3163e28b75cc42e9d1ed21c2e)), closes [#2](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/issues/2)
* **runners:** apps.education projects will use dedicated runners ([3f447c4](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/3f447c40f4d60d84a93e59d14d70c274edc6465b)), closes [#1](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/issues/1)
# [1.1.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/compare/release/1.0.0...release/1.1.0) (2021-11-30)
### Features
* **semantic-release:** use the image build by CI itself ([ba0d024](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/ba0d02416182df2e8ef66d1f4613c95d7ff841ec))
# 1.0.0 (2021-11-30)
### Continuous Integration
* **codeowners:** define @EOLE group members as owners ([5f57f4a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/5f57f4a0033b7a322077696ee2541b10c211892a))
* **commitlint:** master is not always the repository default branch ([48b9f29](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/48b9f29c2d66551e19da00aaf96e16ee1e7d04cd))
* **gitlab-ci:** split in reusable templates ([b39e36b](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/b39e36bd760646385dc8021b5699e61171bbcba1))
* **gitlab:** add commit lint and its documentation ([dfea847](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/dfea8470837e6d77a3c1098e9d00fd25a44b5bf4))
* **rules:** define git-flow style rules ([e8e12e8](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/e8e12e8f2e5aca1eda5798726888b1361ebd1821))
* **codeowners:** define @EOLE group members as owners ([5f57f4a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/5f57f4a0033b7a322077696ee2541b10c211892a))
* **commitlint:** master is not always the repository default branch ([48b9f29](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/48b9f29c2d66551e19da00aaf96e16ee1e7d04cd))
* **gitlab-ci:** split in reusable templates ([b39e36b](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b39e36bd760646385dc8021b5699e61171bbcba1))
* **gitlab:** add commit lint and its documentation ([dfea847](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/dfea8470837e6d77a3c1098e9d00fd25a44b5bf4))
* **rules:** define git-flow style rules ([e8e12e8](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/e8e12e8f2e5aca1eda5798726888b1361ebd1821))
### Features
* **docker:** build images and push them to `${CI_REGISTRY}` ([a18d1f9](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/a18d1f90391c91f517adb102e285d3e0460d1f34))
* **docker:** tag images based on release cycle ([b82a232](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/b82a232ee86a8e9627c116e3a5357fd451170407))
* **gitlab-ci:** automatic release creation with semantic-release ([df92290](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/df9229099f9f7545796bde74ec2c67e2ed10d969))
* **rules:** we prefer release naming over production status ([b7c0cd0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/b7c0cd0ef2f9cff3c0748f1d57927395013c153f))
* **docker:** build images and push them to `${CI_REGISTRY}` ([a18d1f9](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/a18d1f90391c91f517adb102e285d3e0460d1f34))
* **docker:** tag images based on release cycle ([b82a232](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b82a232ee86a8e9627c116e3a5357fd451170407))
* **gitlab-ci:** automatic release creation with semantic-release ([df92290](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/df9229099f9f7545796bde74ec2c67e2ed10d969))
* **rules:** we prefer release naming over production status ([b7c0cd0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b7c0cd0ef2f9cff3c0748f1d57927395013c153f))
This diff is collapsed.
// No release is triggered for the types commented out below.
// Commits using these types will be incorporated into the next release.
//
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
module.exports = [
{breaking: true, release: 'major'},
// {type: 'build', release: 'patch'},
// {type: 'chore', release: 'patch'},
// {type: 'ci', release: 'patch'},
{type: 'docs', release: 'patch'},
{type: 'feat', release: 'minor'},
{type: 'fix', release: 'patch'},
{type: 'perf', release: 'patch'},
{type: 'refactor', release: 'patch'},
{type: 'revert', release: 'patch'},
{type: 'style', release: 'patch'},
{type: 'test', release: 'patch'},
];
module.exports = {
branches: 'stable',
tagFormat: 'release/${version}',
plugins: [
['@semantic-release/commit-analyzer', {
preset: 'angular',
releaseRules: './release-rules.js',
}],
'@semantic-release/release-notes-generator',
['@semantic-release/changelog', {
changelogFile: 'docs/CHANGELOG.md',
changelogTitle: '# Changelog',
}],
['@semantic-release/git', {
assets: ['docs'],
message: 'chore(release): ${nextRelease.version}\n\n${nextRelease.notes}'
}],
'@semantic-release/gitlab',
],
generateNotes: {
preset: 'angular',
writerOpts: {
// Required due to upstream bug preventing all types being displayed.
// Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
// Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
transform: (commit, context) => {
const issues = []
commit.notes.forEach(note => {
note.title = `BREAKING CHANGES`
})
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
if (commit.type === `feat`) {
commit.type = `Features`
} else if (commit.type === `fix`) {
commit.type = `Bug Fixes`
} else if (commit.type === `perf`) {
commit.type = `Performance Improvements`
} else if (commit.type === `revert`) {
commit.type = `Reverts`
} else if (commit.type === `docs`) {
commit.type = `Documentation`
} else if (commit.type === `style`) {
commit.type = `Styles`
} else if (commit.type === `refactor`) {
commit.type = `Code Refactoring`
} else if (commit.type === `test`) {
commit.type = `Tests`
} else if (commit.type === `build`) {
commit.type = `Build System`
// } else if (commit.type === `chore`) {
// commit.type = `Maintenance`
} else if (commit.type === `ci`) {
commit.type = `Continuous Integration`
} else {
return
}
if (commit.scope === `*`) {
commit.scope = ``
}
if (typeof commit.hash === `string`) {
commit.shortHash = commit.hash.substring(0, 7)
}
if (typeof commit.subject === `string`) {
let url = context.repository
? `${context.host}/${context.owner}/${context.repository}`
: context.repoUrl
if (url) {
url = `${url}/issues/`
// Issue URLs.
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
issues.push(issue)
return `[#${issue}](${url}${issue})`
})
}
if (context.host) {
// User URLs.
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
if (username.includes('/')) {
return `@${username}`
}
return `[@${username}](${context.host}/${username})`
})
}
}
// remove references that already appear in the subject
commit.references = commit.references.filter(reference => {
if (issues.indexOf(reference.issue) === -1) {
return true
}
return false
})
return commit
},
},
},
};
# -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml
#
# Define `.build-docker-image` template used by `*-docker-build` jobs
# It build the container image and push it to `${CI_REGISTRY}`
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.docker:image:build`: build a docker image with `kaniko:executor`
#
# - `.docker:image:tag`: tag docker image with `crane`
#
---
#
# .docker:image:build
# ===================
#
# Build the container image `${IMAGE_NAME}:${IMAGE_TAG}` and push it to `${CI_REGISTRY}`
#
# USAGE
# =====
#
# foo-docker-build:
# extends: .build-docker-image
# extends: .docker:image:build
# variables:
# DOCKERFILE: Some-specific.Dockerfile
# IMAGE_TAG: $CI_COMMIT_REF_SLUG
......@@ -16,89 +26,142 @@
# REQUIREMENTS
# ============
#
# - A `build` stage must be present in your pipeline or it must be
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
# - The `.not-on-stable` rules template
#
# - the `.not-on-stable` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `IMAGE_NAME`: defaults to `${CI_JOB_NAME}` with any suffix `-docker-build*` removed
# - `IMAGE_NAME`: name of the docker image to build, defaults to
# `${CI_JOB_NAME}` with any suffix `-docker-build*` removed
#
# - `IMAGE_TAG`: tag of the docker image, defaults to
# `git-${CI_COMMIT_SHORT_SHA}`
#
# - `DOCKERFILE`: defaults, in order
# - to value set by the user
# - to `Dockerfile.${IMAGE_NAME}` if the file exists
# - to `Dockerfile` if the file exists
# - `IMAGE_TAG`: defaults to `git-${CI_COMMIT_SHORT_SHA}`
#
# - `KANIKO_IMAGE`: name of the `kaniko` docker image to use
#
# - `KANIKO_ARGS`: arguments to pass to kaniko executor command, empty
# by default
#
# USED CI VARIABLES
# =================
#
# - `CI_REGISTRY`
#
# - `CI_REGISTRY_USER`
#
# - `CI_REGISTRY_PASSWORD`
#
# - `CI_REGISTRY_IMAGE`
#
.build-docker-image:
.docker:image:build:
stage: build
extends: .not-on-stable
image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug
name: "${KANIKO_IMAGE}"
entrypoint: [""]
variables:
KANIKO_IMAGE: gcr.io/kaniko-project/executor:v1.7.0-debug
KANIKO_ARGS: ''
script:
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-build-config[collapsed=true]\r\e[0KPrepare environment to build docker image"
- export IMAGE_NAME=${IMAGE_NAME:-${CI_JOB_NAME%-docker-build*}}
- test -f Dockerfile.${IMAGE_NAME} && export DOCKERFILE=${DOCKERFILE:-Dockerfile.${IMAGE_NAME}} || true
- test -f Dockerfile && export DOCKERFILE=${DOCKERFILE:-Dockerfile} || true
- export IMAGE_TAG=${IMAGE_TAG:-git-${CI_COMMIT_SHORT_SHA}}
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile $CI_PROJECT_DIR/${DOCKERFILE} --destination ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-build-config\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-build-kaniko\r\e[0KBuild docker image '${IMAGE_NAME}:${IMAGE_TAG}' using Dockerfile '${DOCKERFILE}' and push to '${CI_REGISTRY_IMAGE}'"
- /kaniko/executor ${KANIKO_ARGS} --context ${CI_PROJECT_DIR} --dockerfile $CI_PROJECT_DIR/${DOCKERFILE} --destination ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-build-kaniko\r\e[0K"
.build-docker-image:
extends: .docker:image:build
before_script:
- 'echo "DEPRECATION WARNING: use .docker:image:build instead"'
# Define `.tag-docker-image` template used by `*-docker-tag` jobs
# It tag the `${IMAGE_NAME}:${SOURCE_TAG}` with the tag `${IMAGE_TAG}`
#
# .docker:image:tag
# =================
#
# Tag the `${IMAGE_NAME}:${SOURCE_TAG}` with the new tag `${IMAGE_TAG}`
#
# USAGE
# =====
#
# foo-docker-tag-devel:
# extends: .tag-docker-image
# extends: .docker:image:tag
# variables:
# IMAGE_TAG: 'devel'
#
# REQUIREMENTS
# ============
#
# - A `release` stage must be present in your pipeline or it must be
# - a `release` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
# - The `.not-on-stable` rules template
#
# - the `.on-release-tag` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `IMAGE_NAME`: defaults to `${CI_JOB_NAME}` with any suffix `-docker-tag*` removed
# - `SOURCE_TAG`: source image tag to retag, defaults to `git-${CI_COMMIT_SHORT_SHA}`
# - `IMAGE_TAG`: image tag, defaults to `${CI_COMMIT_TAG}` with prefix `RELEASE_PREFIX` removed
# - `RELEASE_PREFIX`: prefix of the `RELEASE`, defaults to `release/`
# - `IMAGE_NAME`: name of the docker image to tag, defaults to
# `CI_JOB_NAME` with any suffix `-docker-tag*` removed
#
# - `SOURCE_TAG`: source image tag to retag, defaults to
# `git-${CI_COMMIT_SHORT_SHA}`
#
# - `IMAGE_TAG`: image tag, defaults to `${CI_COMMIT_TAG}` with
# prefix `${RELEASE_TAG_PREFIX}` removed
#
# - `RELEASE_TAG_PREFIX`: prefix of the `RELEASE`, defaults to
# `release/`
#
# - `CRANE_IMAGE`: name of the `crane` docker image to use
#
# USED CI VARIABLES
# =================
#
# - `CI_REGISTRY`
#
# - `CI_REGISTRY_USER`
#
# - `CI_REGISTRY_PASSWORD`
#
# - `CI_REGISTRY_IMAGE`
#
.tag-docker-image:
.docker:image:tag:
stage: release
extends: .on-release-tag
image:
name: gcr.io/go-containerregistry/crane:debug
name: "${CRANE_IMAGE}"
entrypoint: [""]
variables:
CRANE_IMAGE: gcr.io/go-containerregistry/crane:debug
GIT_STRATEGY: none
script:
- export IMAGE_NAME=${IMAGE_NAME:-${CI_JOB_NAME%-docker-tag*}}
- export SOURCE_TAG=${SOURCE_TAG:-git-${CI_COMMIT_SHORT_SHA}}
- export RELEASE_PREFIX=${RELEASE_PREFIX:-release/}
- export IMAGE_TAG=${IMAGE_TAG:-${CI_COMMIT_TAG#${RELEASE_PREFIX}}}
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane tag ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${SOURCE_TAG} ${IMAGE_TAG}
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-tag-config[collapsed=true]\r\e[0KPrepare environment to tag docker image"
- export IMAGE_NAME="${IMAGE_NAME:-${CI_JOB_NAME%-docker-tag*}}"
- export SOURCE_TAG="${SOURCE_TAG:-git-${CI_COMMIT_SHORT_SHA}}"
- export RELEASE_TAG_PREFIX="${RELEASE_TAG_PREFIX:-release/}"
- export IMAGE_TAG="${IMAGE_TAG:-${CI_COMMIT_TAG#${RELEASE_TAG_PREFIX}}}"
- crane auth login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-tag-config\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-tag-crane\r\e[0KTag docker image '${IMAGE_NAME}:${SOURCE_TAG}' with '${IMAGE_TAG}'"
- crane tag "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${SOURCE_TAG}" "${IMAGE_TAG}"
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-tag-crane\r\e[0K"
.tag-docker-image:
extends: .docker:image:tag
before_script:
- 'echo "DEPRECATION WARNING: use .docker:image:tag instead"'
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.git:commitlint`: verify formatting of commit messages
#
# - `.git:merge-to`: merge release tags to the `${GIT_MERGE_TARGET}` branch
#
---
#
# .git:commitlint
# ===============
#
# Verify formatting of all commit messages in the range
# `${BASE_BRANCH}..${CI_COMMIT_SHA}`.
#
# USAGE
# =====
#
# include:
# - project: baby-gnu/ci-tools
# ref: main
# file: /templates/Git.yaml
#
# stages:
# - lint
#
# commitlint: {extends: '.git:commitlint'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.on-branch` rules templates or it must be overriden by
# the extending job to feet your need
#
# - a `${CI_COMMIT_SHA}` pointing to the last commit to verify
#
# - a `commitlint` configuration file
#
# OPTIONAL VARIABLES
# ==================
#
# - `BASE_BRANCH`: name of the referrence branch, defaults to
# `${CI_DEFAULT_BRANCH}`
#
# - `GIT_COMMITLINT_IMAGE`: name of the `commitlint` docker image to use
#
# USED CI VARIABLES
# =================
#
# - `CI_COMMIT_SHA`
#
# - `CI_DEFAULT_BRANCH`
#
# SEE ALSO
# ========
#
# - Upstream: https://github.com/conventional-changelog/commitlint/
#
.git:commitlint:
stage: lint
extends: .on-branch
image: "${GIT_COMMITLINT_IMAGE}"
variables:
GIT_COMMITLINT_IMAGE: 'hub.eole.education/eole/commitlint:latest'
BASE_BRANCH: "${CI_DEFAULT_BRANCH}"
script:
- echo -e "\e[0Ksection_start:`date +%s`:git-fetch[collapsed=true]\r\e[0KFetch all remotes"
- 'git fetch --all'
- echo -e "\e[0Ksection_end:`date +%s`:git-fetch\r\e[0K"
# Set default commit hashes for `--from` and `--to`
- echo -e "\e[0Ksection_start:`date +%s`:commitlint-configure[collapsed=true]\r\e[0KCalculate 'COMMITLINT_FROM' and 'COMMITLINT_TO'"
- 'export COMMITLINT_FROM="$(git merge-base origin/${BASE_BRANCH} HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
- echo -e "\e[0Ksection_end:`date +%s`:commitlint-configure\r\e[0K"
# Run `commitlint`
- echo -e "\e[0Ksection_start:`date +%s`:commitlint\r\e[0KVerify commit message between '${COMMITLINT_FROM}..${COMMITLINT_TO}'"
- cd /tmp
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose
--cwd "${CI_PROJECT_DIR}"'
- echo -e "\e[0Ksection_end:`date +%s`:commitlint\r\e[0K"
#
# .git:merge-to
# =============
#
# Merge `${GIT_MERGE_SOURCE}` to a `${GIT_MERGE_TARGET}` branch.
#
# USAGE
# =====
#
# include:
# - project: baby-gnu/ci-tools
# ref: main
# file: /templates/Git.yaml
#
# stages:
# - release
#
# merge-to-dev: {extends: '.git:merge-to', variables: {GIT_MERGE_TARGET: $DEV_BRANCH}}
#
# REQUIREMENTS
# ============
#
# - a `release` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.on-release-tag` rules templates or it must be overriden by
# the extending job to feet your need
#
# - a `${GIT_MERGE_TARGET}` branch name
#
# - a `${GIT_MERGE_SOURCE}` reference, by default `${CI_COMMIT_TAG}`
#
# - a `${GITLAB_TOKEN}` to push the merged `${GIT_MERGE_TARGET}`
# branch
#
# OPTIONAL VARIABLES
# ==================
#
# - `GIT_AUTHOR_NAME`: name of the optional merge commit author,
# extracted from `CI_COMMIT_AUTHOR` by default
#
# - `GIT_AUTHOR_EMAIL`: email of the optional merge commit author,
# extracted from `CI_COMMIT_AUTHOR` by default
#
# - `GIT_COMMITTER_NAME`: name of the optional merge commit committer,
# default to `${GIT_AUTHOR_NAME}`
#
# - `GIT_COMMITTER_EMAIL`: email of the optional merge commit, default
# to `${GIT_AUTHOR_EMAIL}`
#
# - `GIT_MERGE_TO_IMAGE`: name of the docker image to execute `git`
# commands
#
# USED CI VARIABLES
# =================
#
# - `CI_COMMIT_TAG`
#
# - `CI_COMMIT_AUTHOR`
#
# - `CI_REPOSITORY_URL`
#
# - `CI_JOB_TOKEN`
#
.git:merge-to:
stage: release
extends: .on-release-tag
image: "${GIT_MERGE_TO_IMAGE}"
variables:
GIT_MERGE_TO_IMAGE: 'bitnami/git:latest'
GIT_MERGE_SOURCE: ${CI_COMMIT_TAG}
GIT_MERGE_TARGET: ''
script:
# Configure git to be able to create merge commit
# Extract author name and mail if not SET
- echo -e "\e[0Ksection_start:`date +%s`:git-configure[collapsed=true]\r\e[0KConfigure git variables from '${CI_COMMIT_AUTHOR}'"
- export GIT_AUTHOR_NAME="${GIT_AUTHOR_NAME:-${CI_COMMIT_AUTHOR% <*}}"
- export TEMP_MAIL_PREFIX="${CI_COMMIT_AUTHOR#*<}"
- export GIT_AUTHOR_EMAIL="${GIT_AUTHOR_EMAIL:-${TEMP_MAIL_PREFIX%>}}"
- export GIT_COMMITTER_NAME="${GIT_COMMITTER_NAME:-${GIT_AUTHOR_NAME}}"
- export GIT_COMMITTER_EMAIL="${GIT_COMMITTER_EMAIL:-${GIT_AUTHOR_EMAIL}}"
- echo -e "\e[0Ksection_end:`date +%s`:git-configure\r\e[0K"
# Add `upstream` remote to get access to `upstream/dev`
# Use `${GITLAB_TOKEN}` for write permission
- echo -e "\e[0Ksection_start:`date +%s`:git-remote-upstream-add[collapsed=true]\r\e[0KAdd upstream repository and checkout '${GIT_MERGE_TARGET}'"
- "git remote show upstream 2> /dev/null || git remote add upstream ${CI_REPOSITORY_URL/${CI_JOB_TOKEN}/${GITLAB_TOKEN}}"
- 'git fetch --all'
- 'git checkout -B ${GIT_MERGE_TARGET} upstream/${GIT_MERGE_TARGET}'
- echo -e "\e[0Ksection_end:`date +%s`:git-remote-upstream-add\r\e[0K"
# Merge the release tag
- echo -e "\e[0Ksection_start:`date +%s`:git-merge-release[collapsed=true]\r\e[0KMerge '${GIT_MERGE_SOURCE}' in '${GIT_MERGE_TARGET}'"
- 'git merge --no-edit ${GIT_MERGE_SOURCE}'
- 'git push upstream ${GIT_MERGE_TARGET}'
- echo -e "\e[0Ksection_end:`date +%s`:git-merge-release\r\e[0K"
# Remove `upstream` to avoid caching `${GITLAB_TOKEN}`
- echo -e "\e[0Ksection_start:`date +%s`:git-cleanup[collapsed=true]\r\e[0KCleanup git repository"
- "git remote remove upstream"
- echo -e "\e[0Ksection_end:`date +%s`:git-cleanup\r\e[0K"
...
# -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.helm:lint`: verify formatting of the helm chart
#
# - `.helm:package`: build the helm package tgz file
#
# - `.helm:cm-push`: push the helm package tgz file to a remote
# repository
#
---
#
# .helm:lint
# ==========
#
# Verify formatting of the helm chart files.
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: master
# file: /templates/Helm.yaml
#
# stages:
# - lint
#
# helm lint: {extends: '.helm:lint'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.not-on-stable` rules templates or it must be overriden by
# the extending job to feet your need
#
# OPTIONAL VARIABLES
# ==================
#
# - `CHART_DIR`: directory of the helm chart, default to `.`
#
# - `HELM_IMAGE`: name of the `helm` docker image to use
#
# - `HELM_ARGS`: optional arguments to pass to `helm lint` command,
# empty by default
#
# USED CI VARIABLES
# =================
#
.helm:lint:
stage: lint
extends:
- .helm:base
- .not-on-stable
script:
- echo -e "\e[0Ksection_start:$(date +%s):helm-lint\r\e[0KExecute 'helm lint ${HELM_ARGS} ${CHART_DIR}'"
- helm lint ${HELM_ARGS} "${CHART_DIR}"
- echo -e "\e[0Ksection_end:$(date +%s):helm-lint\r\e[0K"
#
# .helm:package
# =============
#
# Build the helm package tgz file
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: master
# file: /templates/Helm.yaml
#
# stages:
# - build
#
# helm build: {extends: '.helm:package'}
#
# REQUIREMENTS
# ============
#
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.not-on-stable` rules templates or it must be overriden by
# the extending job to feet your need
#
# OPTIONAL VARIABLES
# ==================
#
# - `CHART_DIR`: directory of the helm chart, default to `.`
#
# - `HELM_IMAGE`: name of the `helm` docker image to use
#
# - `HELM_ARGS`: optional arguments to pass to `helm package` command,
# empty by default
#
# - `HELM_BUILD_DIR`: write package chart in this directory, default
# to `build`
#
# USED CI VARIABLES
# =================
#
.helm:package:
stage: build
extends:
- .helm:base
- .not-on-stable
artifacts:
paths:
- $HELM_BUILD_DIR
script:
- echo -e "\e[0Ksection_start:$(date +%s):helm-package\r\e[0KExecute 'helm package --destination ${HELM_BUILD_DIR} ${HELM_ARGS} ${CHART_DIR}'"
- helm package --destination "${HELM_BUILD_DIR}" ${HELM_ARGS} "${CHART_DIR}"
- echo -e "\e[0Ksection_end:$(date +%s):helm-package\r\e[0K"
#
# .helm:cm-push
# =============
#
# Push the helm package tgz file to a remote chartMuseum repository
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: master
# file: /templates/Helm.yaml
#
# stages:
# - release
#
# helm publish: {extends: '.helm:cm-push'}
#
# REQUIREMENTS
# ============
#
# - a `release` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.on-release-tag` rules templates or it must be overriden by
# the extending job to feet your need
#
# - `HELM_REPO` variable: URL of the helm ChartMuseum
#
# - `HELM_REPO_USERNAME` variable: name of the user with write access
# to the ChartMuseum
#
# - `HELM_REPO_PASSWORD` variable: password of `HELM_REPO_USERNAME`
#
# OPTIONAL VARIABLES
# ==================
#
# - `CHART_DIR`: directory of the helm chart, default to `.`
#
# - `HELM_IMAGE`: name of the `helm` docker image to use
#
# - `HELM_ARGS`: optional arguments to pass to `helm cm-push` command,
# empty by default
#
# - `HELM_BUILD_DIR`: write package chart in this directory, default
# to `build`
#
# USED CI VARIABLES
# =================
#
.helm:cm-push:
stage: release
extends:
- .helm:base
- .on-release-tag
script:
- echo -e "\e[0Ksection_start:$(date +%s):helm-cm-push-config[collapsed=true]\r\e[0KPrepare environment to push to helm remote repository '${HELM_REPO}'"
- helm repo add chartrepo "${HELM_REPO}"
- echo -e "\e[0Ksection_end:$(date +%s):helm-cm-push-config\r\e[0K"
- echo -e "\e[0Ksection_start:$(date +%s):helm-cm-push\r\e[0KExecute 'helm cm-push ${HELM_BUILD_DIR}/* chartrepo'"
- helm cm-push "${HELM_BUILD_DIR}"/* chartrepo
- echo -e "\e[0Ksection_end:$(date +%s):helm-cm-push\r\e[0K"
.helm:base:
extends: .not-on-stable
image:
name: "${HELM_IMAGE}"
variables:
HELM_IMAGE: hub.eole.education/eole/helm:latest
HELM_ARGS: ''
HELM_BUILD_DIR: 'build'
CHART_DIR: '.'
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Backward compatible template.
# Use `templates/Git.yaml` instead
#
---
commitlint:
stage: lint
extends: .not-on-stable
image: 'hub.eole.education/eole/commitlint:latest'
before_script:
# Add `upstream` remote to get access to `upstream/master`
- "git remote show upstream 2> /dev/null || git remote add upstream ${CI_REPOSITORY_URL}"
- 'git fetch --all'
after_script:
# Remove `upstream` to avoid caching `CI_JOB_TOKEN`
- "git remote remove upstream"
include:
local: /templates/Git.yaml
commitlint: {extends: '.git:commitlint'}
deprecation-commitlint:
# Execute at the same time
extends: commitlint
# The failure must be a warning
allow_failure: true
script:
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base upstream/${CI_DEFAULT_BRANCH} HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
- 'echo "DEPRECATION WARNING: replace commitlint by .git:commitlint"'
- 'echo "DEPRECATION WARNING: see /templates/Git.yaml"'
# Be visible in the CI pipeline
- '/bin/false'
...
# -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.maven:validate`: validate the project is correct and all
# necessary information is available
#
# - `.maven:verify`: run any checks on results of integration tests to
# ensure quality criteria are met
#
# - `.maven:deploy`: copies the final package to the remote repository
#
# - `.maven:base`: base template job used to factorize variables
# declaration
#
---
#
# .maven:validate
# ===============
#
# Validate the project is correct and all necessary information is
# available.
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Maven.yaml
#
# stages:
# - lint
#
# maven validate: {extends: '.maven:validate'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.on-branch` rules templates or it must be overriden by
# the extending job to feet your need
#
# OPTIONAL VARIABLES
# ==================
#
# - `SRC_DIR`: directory of the java sources containing the `pom.xml`,
# default to `.`
#
# - `MAVEN_IMAGE`: name of the `maven` docker image to use
#
# - `MAVEN_OPTS`: default to "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
#
# - `MAVEN_CLI_OPTS`: default to "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
#
# - `MAVEN_CLI_ARGS`: optional arguments to pass to `maven validate`
# command, empty by default
#
# USED CI VARIABLES
# =================
#
.maven:validate:
stage: lint
extends: .maven:base
cache:
# This job update dependencies
policy: pull-push
script:
- echo -e "\e[0Ksection_start:$(date +%s):maven-validate\r\e[0KExecute 'mvn validate -f ${SRC_DIR} ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}'"
- mvn validate -f "${SRC_DIR}" ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}
- echo -e "\e[0Ksection_end:$(date +%s):maven-validate\r\e[0K"
#
# .maven:verify
# =============
#
# Run any checks on results of integration tests to ensure quality
# criteria are met.
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Maven.yaml
#
# stages:
# - test
#
# maven verify: {extends: '.maven:verify'}
#
# REQUIREMENTS
# ============
#
# - a `test` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.on-branch` rules templates or it must be overriden by
# the extending job to feet your need
#
# OPTIONAL VARIABLES
# ==================
#
# - `SRC_DIR`: directory of the java sources containing the `pom.xml`,
# default to `.`
#
# - `MAVEN_IMAGE`: name of the `maven` docker image to use
#
# - `MAVEN_OPTS`: default to "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
#
# - `MAVEN_CLI_OPTS`: default to "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
#
# - `MAVEN_CLI_ARGS`: optional arguments to pass to `maven verify`
# command, empty by default
#
# USED CI VARIABLES
# =================
#
.maven:verify:
stage: test
extends: .maven:base
script:
- echo -e "\e[0Ksection_start:$(date +%s):maven-verify\r\e[0KExecute 'mvn verify -f ${SRC_DIR} ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}'"
- mvn verify -f "${SRC_DIR}" ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}
- echo -e "\e[0Ksection_end:$(date +%s):maven-verify\r\e[0K"
#
# .maven:deploy
# =============
#
# Copies the final package to the remote repository for sharing with
# other developers and projects.
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Maven.yaml
#
# stages:
# - release
#
# maven deploy: {extends: '.maven:deploy'}
#
# REQUIREMENTS
# ============
#
# - a `release` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# - the `.on-stable` rules templates or it must be overriden by the
# extending job to feet your need
#
# OPTIONAL VARIABLES
# ==================
#
# - `SRC_DIR`: directory of the java sources containing the `pom.xml`,
# default to `.`
#
# - `MAVEN_IMAGE`: name of the `maven` docker image to use
#
# - `MAVEN_OPTS`: default to "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
#
# - `MAVEN_CLI_OPTS`: default to "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
#
# - `MAVEN_CLI_ARGS`: optional arguments to pass to `maven deploy`
# command, empty by default
#
# USED CI VARIABLES
# =================
#
.maven:deploy:
stage: release
extends:
- .maven:base
- .on-stable
script:
- echo -e "\e[0Ksection_start:$(date +%s):maven-deploy\r\e[0KExecute 'mvn deploy -s ci_settings.xml -f ${SRC_DIR} ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}'"
- mvn deploy -f "${SRC_DIR}" ${MAVEN_CLI_OPTS} ${MAVEN_CLI_ARGS}
- echo -e "\e[0Ksection_end:$(date +%s):maven-deploy\r\e[0K"
.maven:base:
image: ${MAVEN_IMAGE}
extends: .on-branch
variables:
SRC_DIR: '.'
MAVEN_IMAGE: hub.eole.education/proxyhub/library/maven:3.8.6-openjdk-8-slim
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
MAVEN_CLI_ARGS: ""
cache:
key:
files:
- pom.xml
paths:
- .m2/repository
# Validate will push the cache
policy: pull
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.python:black:check`: verify formatting of code with `black`
#
# - `.python:build`: build the `sdist` and `wheel` packages
#
# - `.python:build:sdist`: build the `sdist` package
#
# - `.python:build:wheel`: build the `wheel` package
#
---
#
# .python:black:check
# ===================
#
# The Python code must match `black` standard.
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Python.yaml
#
# stages:
# - lint
#
# python:black: {extends: '.python:black:check'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.not-on-stable` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `PYTHON_BLACK_OPTS`: additional options to pass to `black`
#
# - `PYTHON_SOURCE_DIR`: top level directory where to run `black`,
# defaults to `.`
#
# - `PYTHON_BLACK_IMAGE`: name of the black docker image to use
#
.python:black:check:
stage: lint
extends: .not-on-stable
image: "${PYTHON_BLACK_IMAGE}"
variables:
PYTHON_BLACK_IMAGE: "hub.eole.education/proxyhub/pyfound/black:latest_release"
PYTHON_BLACK_OPTS: ''
PYTHON_SOURCE_DIR: '.'
script:
- echo -e "\e[0Ksection_start:`date +%s`:python-black\r\e[0KExecute 'black --check ${PYTHON_BLACK_OPTS} ${PYTHON_SOURCE_DIR}'"
- black --check ${PYTHON_BLACK_OPTS} ${PYTHON_SOURCE_DIR}
- echo -e "\e[0Ksection_end:`date +%s`:python-black\r\e[0K"
#
# .python:build
# =============
#
# Build the python `sdist` and `wheel` packages with the `build` module
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Python.yaml
#
# stages:
# - build
#
# python:build {extends: '.python:build'}
#
# REQUIREMENTS
# ============
#
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.rules-map` rules templates
#
# - a `pyproject.toml` or `setup.py` file
#
# OPTIONAL VARIABLES
# ==================
#
# - `PYTHON_DIST_FILES`: files to upload, defaults to `dist/*'
#
# - `PYTHON_SOURCE_DIR`: top level directory of python source where to
# find `pyproject.toml` or `setup.py`, defaults to `.'
#
# - `PYTHON_BUILD_OPTS`: additional options to pass to the
# `pyproject-build` command line
#
# - `PYTHON_IMAGE`: name of the python docker image to use
#
# SEE ALSO
# ========
#
# - https://pypi.org/project/build/
#
.python:build:
stage: build
extends: .python:base
variables:
PYTHON_DIST_FILES: dist/*
artifacts:
paths:
- ${PYTHON_SOURCE_DIR}/${PYTHON_DIST_FILES}
script:
- echo -e "\e[0Ksection_start:`date +%s`:python-build-deps[collapsed=true]\r\e[0KInstall 'build' module"
- pip install build
- echo -e "\e[0Ksection_end:`date +%s`:python-build-deps\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:python-build\r\e[0KBuild distribution 'sdist' and 'wheel' from '${PYTHON_SOURCE_DIR}'"
- pyproject-build ${PYTHON_BUILD_OPTS} "${PYTHON_SOURCE_DIR}"
- echo -e "\e[0Ksection_end:`date +%s`:python-build\r\e[0K"
#
# .python:build:sdist
# ===================
#
# Build the python source `.tar.gz` with the `build` module
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Python.yaml
#
# stages:
# - build
#
# python:build:source {extends: '.python:build:sdist'}
#
# REQUIREMENTS
# ============
#
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.rules-map` rules templates
#
# - a `pyproject.toml` or `setup.py` file
#
# OPTIONAL VARIABLES
# ==================
#
# - `PYTHON_DIST_FILES`: files to upload, defaults to `dist/*.tar.gz'
#
# - `PYTHON_SOURCE_DIR`: top level directory of python source where to
# find `pyproject.toml` or `setup.py`, defaults to `.'
#
# - `PYTHON_BUILD_OPTS`: additional options to pass to the
# `pyproject-build` command line
#
# - `PYTHON_IMAGE`: name of the python docker image to use
#
# SEE ALSO
# ========
#
# - https://pypi.org/project/build/
#
.python:build:sdist:
extends: .python:build
variables:
PYTHON_DIST_FILES: dist/*.tar.gz
script:
- echo -e "\e[0Ksection_start:`date +%s`:python-build-sdist-deps[collapsed=true]\r\e[0KInstall 'build' module"
- pip install build
- echo -e "\e[0Ksection_end:`date +%s`:python-build-sdist-deps\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:python-build-sdist\r\e[0KBuild distribution 'sdist' from '${PYTHON_SOURCE_DIR}'"
- pyproject-build --sdist ${PYTHON_BUILD_OPTS} "${PYTHON_SOURCE_DIR}"
- echo -e "\e[0Ksection_end:`date +%s`:python-build-sdist\r\e[0K"
#
# .python:build:wheel
# ===================
#
# Build the python source `.tar.gz` with the `build` module
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Python.yaml
#
# stages:
# - build
#
# python:build:source {extends: '.python:build:wheel'}
#
# REQUIREMENTS
# ============
#
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.rules-map` rules templates
#
# - a `pyproject.toml` or `setup.py` file
#
# OPTIONAL VARIABLES
# ==================
#
# - `PYTHON_DIST_FILES`: files to upload, defaults to `dist/*.whl'
#
# - `PYTHON_SOURCE_DIR`: top level directory of python source where to
# find `pyproject.toml` or `setup.py`, defaults to `.'
#
# - `PYTHON_BUILD_OPTS`: additional options to pass to the
# `pyproject-build` command line
#
# - `PYTHON_IMAGE`: name of the python docker image to use
#
# SEE ALSO
# ========
#
# - https://pypi.org/project/build/
#
.python:build:wheel:
extends: .python:build
variables:
PYTHON_DIST_FILES: dist/*.whl
script:
- echo -e "\e[0Ksection_start:`date +%s`:python-build-wheel-deps[collapsed=true]\r\e[0KInstall 'build' module"
- pip install build
- echo -e "\e[0Ksection_end:`date +%s`:python-build-wheel-deps\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:python-build-wheel\r\e[0KBuild distribution 'wheel' from '${PYTHON_SOURCE_DIR}'"
- pyproject-build --wheel ${PYTHON_BUILD_OPTS} "${PYTHON_SOURCE_DIR}"
- echo -e "\e[0Ksection_end:`date +%s`:python-build-wheel\r\e[0K"
#
# .python:upload
# ==============
#
# Upload python package files to the registry
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: stable
# file: /templates/Python.yaml
#
# stages:
# - build
#
# python:upload {extends: '.python:upload'}
#
# REQUIREMENTS
# ============
#
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.on-release-tag` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `PYTHON_DIST_FILES`: files to upload, defaults to `dist/*'
#
# - `PYTHON_SOURCE_DIR`: top level directory of python source where to
# find `setup.py`, defaults to `.`
#
# - `PYTHON_REPOSITORY_URL`: pypi repository URL, defaults to
# `${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi`
#
# - `PYTHON_IMAGE`: name of the python docker image to use
#
.python:upload:
stage: release
extends:
- .python:base
- .on-release-tag
variables:
PYTHON_REPOSITORY_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
script:
- echo -e "\e[0Ksection_start:`date +%s`:python-twine-upload\r\e[0KUpload '${PYTHON_SOURCE_DIR}/${PYTHON_DIST_FILES}' to repository '${PYTHON_REPOSITORY_URL}'"
- cd ${PYTHON_SOURCE_DIR}
- pip install twine
- 'TWINE_PASSWORD=${CI_JOB_TOKEN}
TWINE_USERNAME=gitlab-ci-token
python -m twine upload
--repository-url ${PYTHON_REPOSITORY_URL}
${PYTHON_DIST_FILES}'
- echo -e "\e[0Ksection_end:`date +%s`:python-twine-upload\r\e[0K"
#
# .python:base
# ============
#
# Base template for build and upload
# Run on all branches, release and prerelease tags
#
.python:base:
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, on-release-tag]
- !reference [.rules-map, on-testing-tag]
- !reference [.rules-map, on-dev-tag]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branch]
image: "${PYTHON_IMAGE}"
variables:
PYTHON_IMAGE: "hub.eole.education/proxyhub/library/python:latest"
PYTHON_SOURCE_DIR: '.'
PYTHON_DIST_FILES: 'dist/*'
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# Produce a new release using semantic versionning scheme when new
# commits arrive on the production branch.
#
# USAGE
# =====
#
# include:
# - project: EOLE/infra/ci-tools
# ref: stable
# file: /templates/Release/Semantic-release.yaml
#
# REQUIREMENTS
# ============
#
# - A `release` stage must be present in your pipeline
# - One of the `semantic-release` configuration file must be present
# - `release.config.js`
# - `.releaserc`
# - `.releaserc.js`
# - `.releaserc.json`
# - `.releaserc.yaml`
# - `.releaserc.yml`
# - an access token named `GITLAB_TOKEN` with
# - `api`
# - `read_repository`
# - `write_repository`
# - The variable `$STABLE_BRANCH` defined
#
# OPTIONAL VARIABLES
# ==================
# Backward compatible template.
# Use `templates/Semantic-release.yaml` instead
#
# - `SEMANTIC_RELEASE_IMAGE`: name of the `semantic-release` docker
# image to use
#
# SEE ALSO
# ========
#
# - Semantic release software: https://github.com/semantic-release/semantic-release/
# - Commitlint: https://github.com/conventional-changelog/commitlint/
#
# IMPORTANT NOTE
# ==============
#
# We can't merge rules with `!reference` until we switch to Gitlab >= 14.3
# https://gitlab.com/gitlab-org/gitlab/-/issues/322992
---
include:
local: /templates/Semantic-release.yaml
.on-stable-with-semantic-release-config:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude semantic-release commits on $STABLE_BRANCH
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
exists:
- release.config.js
- .releaserc
- .releaserc.yaml
- .releaserc.yml
- .releaserc.json
- .releaserc.js
when: on_success
semantic-release: {extends: '.semantic-release:stable'}
semantic-release:
stage: release
extends: .on-stable-with-semantic-release-config
image: "$SEMANTIC_RELEASE_IMAGE"
variables:
SEMANTIC_RELEASE_IMAGE: 'hub.eole.education/eole/semantic-release-gitlab:latest'
deprecation-semantic-release:
# Execute at the same time
extends: semantic-release
# The failure must be a warning
allow_failure: true
script:
- 'semantic-release'
- 'echo "DEPRECATION WARNING: replace semantic-release by .semantic-release:stable"'
- 'echo "DEPRECATION WARNING: see /templates/Semantic-release.yaml"'
# Be visible in the CI pipeline
- '/bin/false'
...
......@@ -37,6 +37,7 @@
# - `wip foo`
# - `foo (draft)`
# - `foo [WIP]`
# - message generated by `semantic-release`
---
variables:
STABLE_BRANCH: stable
......@@ -47,97 +48,138 @@ variables:
BUGFIX_PREFIX: bugfix/
FEATURE_PREFIX: feature/
# This rules template should be used as the default rules.
# It select all branches except the stable one.
# We always exclude schedules.
.not-on-stable:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
- if: $CI_COMMIT_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-stable]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branch]
# Select only branches that are not stable, testing or development.
# We always exclude schedules.
.on-branches:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: never
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: never
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
- if: $CI_COMMIT_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-tag]
- !reference [.rules-map, not-on-stable]
- !reference [.rules-map, not-on-testing]
- !reference [.rules-map, not-on-dev]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branch]
# Select branches
.on-branch:
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-tag]
- !reference [.rules-map, on-branch]
# Select the developpment branch except for commits comming from `semantic-release`
# We always exclude schedules.
# Select the developpment branch
.on-dev:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-dev]
# Select the pre-release testing branch except for commits comming from `semantic-release`
# We always exclude schedules.
# Select the pre-release testing branch
.on-testing:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-testing]
# Select the stable branch except for commits comming from `semantic-release`
# We always exclude schedules.
# Select the stable branch
.on-stable:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-stable]
# Select the protected release tags
# We always exclude schedules.
.on-release-tag:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, on-release-tag]
# Select the protected testing tags
.on-testing-tag:
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, on-testing-tag]
# Select the protected dev tags
.on-dev-tag:
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, on-dev-tag]
# We use a single rules hash to be referenced as array elements by
# individual rules templates above.
# This avoid the duplication of rules conditions
#
# SEE ALSO
# ========
#
# - https://forum.gitlab.com/t/add-conditions-to-rules-array-merged-with-reference/62600
# - https://gitlab.com/gitlab-org/gitlab/-/issues/322992
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67922
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67922
.rules-map:
not-on-schedule:
if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
not-on-tag:
if: $CI_COMMIT_TAG
when: never
not-on-stable:
if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: never
not-on-testing:
if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: never
not-on-dev:
if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: never
not-on-draft:
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
when: on_success
if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
not-on-semantic-release-commit:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
if: $CI_COMMIT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
on-branch:
if: $CI_COMMIT_BRANCH
when: on_success
on-stable:
if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: on_success
on-testing:
if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: on_success
on-dev:
if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: on_success
on-tag:
if: $CI_COMMIT_TAG
when: on_success
on-release-tag:
if: $CI_COMMIT_TAG =~ /^release\/[0-9]+\.[0-9]+\.[0-9]+$/ && $CI_COMMIT_REF_PROTECTED
when: on_success
on-testing-tag:
if: $CI_COMMIT_TAG =~ /^release\/[0-9]+\.[0-9]+\.[0-9]+-testing/ && $CI_COMMIT_REF_PROTECTED
when: on_success
on-dev-tag:
if: $CI_COMMIT_TAG =~ /^release\/[0-9]+\.[0-9]+\.[0-9]+-dev/ && $CI_COMMIT_REF_PROTECTED
when: on_success
...