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 (96)
Showing
with 1949 additions and 424 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 @@ ...@@ -4,9 +4,9 @@
include: include:
- local: templates/Rules.yaml - local: templates/Rules.yaml
- local: templates/Runners/eole-docker.yaml - local: templates/Runners/eole-docker.yaml
- local: templates/Lint/Commitlint.yaml - local: templates/Git.yaml
- local: templates/Docker.yaml - local: templates/Docker.yaml
- local: templates/Release/Semantic-release.yaml - local: templates/Semantic-release.yaml
stages: stages:
- lint - lint
...@@ -16,7 +16,15 @@ stages: ...@@ -16,7 +16,15 @@ stages:
.docker-matrix: .docker-matrix:
parallel: parallel:
matrix: 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` # `build` stage: `*-docker-build`
...@@ -25,16 +33,28 @@ stages: ...@@ -25,16 +33,28 @@ stages:
build-docker: build-docker:
extends: extends:
- .docker-matrix - .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 # Suffix all jobs to avoid conflict with other jobs names
.tag-docker: .tag-docker:
extends: extends:
- .docker-matrix - .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 ## dev images
tag dev: tag dev:
......
...@@ -9,16 +9,76 @@ const gitAssets = []; ...@@ -9,16 +9,76 @@ const gitAssets = [];
// Configure your branches names // Configure your branches names
const stableBranch = 'stable'; const stableBranch = 'stable';
// Assign a branch name to produce a `testing` prerelease tag // Assign a branch name to produce a `beta` prerelease tag
const testingBranch = undefined; 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 // Assign a branch name to produce a `dev` prerelease tag
const devBranch = undefined; 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]; const semanticBranches = [stableBranch];
if (testingBranch) { if (betaBranch) {
semanticBranches.push({ semanticBranches.push({
name: testingBranch, name: betaBranch,
prerelease: true
});
}
if (alphaBranch) {
semanticBranches.push({
name: alphaBranch,
prerelease: true prerelease: true
}); });
} }
...@@ -38,11 +98,39 @@ const config = { ...@@ -38,11 +98,39 @@ const config = {
[ [
'@semantic-release/commit-analyzer', '@semantic-release/commit-analyzer',
{ {
preset: 'angular', preset: 'conventionalcommits',
releaseRules: './release-rules.js', 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}}',
},
}, },
], ],
'@semantic-release/release-notes-generator',
], ],
}; };
...@@ -54,11 +142,11 @@ if ( ...@@ -54,11 +142,11 @@ if (
config.plugins.push([ config.plugins.push([
'@semantic-release/changelog', '@semantic-release/changelog',
{ {
changelogFile: 'docs/CHANGELOG.md', changelogFile: changelogFile,
changelogTitle: '# Changelog', changelogTitle: '# Changelog',
}, },
]); ]);
gitAssets.push('docs/CHANGELOG.md'); gitAssets.push(changelogFile);
} }
// // We need to update package*.json // // We need to update package*.json
...@@ -75,17 +163,32 @@ if ( ...@@ -75,17 +163,32 @@ if (
// ); // );
// gitAssets.push('app/package*.json'); // gitAssets.push('app/package*.json');
// // We need to update setup.py // // 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( // config.plugins.push(
// [ // [
// 'semantic-release-pypi', // 'semantic-release-helm3',
// { // {
// setupPy: 'setup.py', // chartPath: chartDir,
// pypiPublish: false, // onlyUpdateVersion: true,
// }, // },
// ] // ]
// ); // );
// gitAssets.push('setup.cfg'); // gitAssets.push(chartDir.concat('/Chart.yaml'));
// Commit changes and create release on Gitlab // Commit changes and create release on Gitlab
config.plugins.push( config.plugins.push(
...@@ -99,89 +202,4 @@ config.plugins.push( ...@@ -99,89 +202,4 @@ config.plugins.push(
'@semantic-release/gitlab', '@semantic-release/gitlab',
); );
config.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
/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["commit", "note"] }] */
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 null;
}
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;
},
},
};
module.exports = config; module.exports = config;
...@@ -2,8 +2,8 @@ FROM node:current-alpine ...@@ -2,8 +2,8 @@ FROM node:current-alpine
LABEL maintainer="eole@ac-dijon.fr" LABEL maintainer="eole@ac-dijon.fr"
ARG COMMITLINT_VERSION=13 ARG COMMITLINT_VERSION=16
ARG COMMITLINT_CONFIG_CONVENTIONAL_VERSION=13 ARG COMMITLINT_CONFIG_CONVENTIONAL_VERSION=16
RUN apk add --no-cache git \ RUN apk add --no-cache git \
ca-certificates 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,28 +2,23 @@ FROM node:current-alpine ...@@ -2,28 +2,23 @@ FROM node:current-alpine
LABEL maintainer="eole@ac-dijon.fr" LABEL maintainer="eole@ac-dijon.fr"
ARG SEMANTIC_RELEASE_VERSION=18 ARG SEMANTIC_RELEASE_VERSION=19
ARG SEMAINTIC_GITLAB_VERSION=7 ARG SEMAINTIC_GITLAB_VERSION=8
ARG SEMAINTIC_CHANGELOG_VERSION=6 ARG SEMAINTIC_CHANGELOG_VERSION=6
ARG CONVENTIONALCOMMITS_VERSION=4
ARG SEMAINTIC_EXEC_VERSION=6 ARG SEMAINTIC_EXEC_VERSION=6
ARG SEMAINTIC_GIT_VERSION=10 ARG SEMAINTIC_GIT_VERSION=10
ARG SEMANTIC_PYPI_VERSION=2 ARG SEMANTIC_NPM_VERSION=9
ARG SEMANTIC_HELM_VERSION=2
RUN apk add --no-cache git \ RUN apk add --no-cache git \
ca-certificates \ ca-certificates
py3-mock \
py3-pip \
py3-setuptools \
py3-twine \
py3-wheel \
python3
# semantic-release-pypi requires the `python` binary
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN npm install -g semantic-release@${SEMAINTIC_RELEASE_VERSION} \ RUN npm install -g semantic-release@${SEMAINTIC_RELEASE_VERSION} \
@semantic-release/gitlab@${SEMAINTIC_GITLAB_VERSION} \ @semantic-release/gitlab@${SEMAINTIC_GITLAB_VERSION} \
@semantic-release/changelog@${SEMAINTIC_CHANGELOG_VERSION} \ @semantic-release/changelog@${SEMAINTIC_CHANGELOG_VERSION} \
@semantic-release/exec@${SEMAINTIC_EXEC_VERSION} \ @semantic-release/exec@${SEMAINTIC_EXEC_VERSION} \
@semantic-release/git@${SEMAINTIC_GIT_VERSION} \ @semantic-release/git@${SEMAINTIC_GIT_VERSION} \
semantic-release-pypi@${SEMANTIC_PYPI_VERSION} @semantic-release/npm@${SEMAINTIC_NPM_VERSION} \
conventional-changelog-conventionalcommits@${CONVENTIONALCOMMITS_VERSION} \
semantic-release-helm3@${SEMANTIC_HELM_VERSION}
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 # Changelog
# [1.3.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/compare/release/1.2.1...release/1.3.0) (2022-01-11) ## [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
* **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 ### Bug Fixes
* **semantic-release:** the branch must be `stable` ([4b9152d](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/4b9152dcae29a8cd792de452041d47da6bf6807c)) * **semantic-release:** the branch must be `stable` ([4b9152d](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/4b9152dcae29a8cd792de452041d47da6bf6807c))
### Code Refactoring ### Code Refactoring
* **commitlint:** the upstream extra repository is useless ([cdff4ab](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/cdff4abd8af608b8ab31398c0a6703a50eae0e08)) * **commitlint:** the upstream extra repository is useless ([cdff4ab](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/cdff4abd8af608b8ab31398c0a6703a50eae0e08))
### Documentation ### Documentation
* **commitlint:** describe usage of the commitlint job ([8b3749f](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/8b3749f044227c390e15480c63f125c24e99767a)) * **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)) * **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)) * **readme:** demonstrate a possible release cycle ([8d02a0c](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/8d02a0cf712cb590cfc3a65d7231a9157bcbbbb6))
### Features ### 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 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)) * **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)) * **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:** 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)) * **semantic-release:** manage python projects releases ([9794bcb](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/9794bcb0b7d427af10e99a65723456953f575182))
### Styles ### Styles
* **js:** js configuration files do not pass eslint ([5874dca](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/5874dca35effe04f82ff848918706a15012dcf73)) * **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) ## [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 ### 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) * **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) # [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 ### 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) * **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) * **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) # [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 ### Features
* **semantic-release:** use the image build by CI itself ([ba0d024](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/ba0d02416182df2e8ef66d1f4613c95d7ff841ec)) * **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) # 1.0.0 (2021-11-30)
### Continuous Integration ### Continuous Integration
* **codeowners:** define @EOLE group members as owners ([5f57f4a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/5f57f4a0033b7a322077696ee2541b10c211892a)) * **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)) * **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-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)) * **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)) * **rules:** define git-flow style rules ([e8e12e8](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/e8e12e8f2e5aca1eda5798726888b1361ebd1821))
### Features ### Features
* **docker:** build images and push them to `${CI_REGISTRY}` ([a18d1f9](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/a18d1f90391c91f517adb102e285d3e0460d1f34)) * **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)) * **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)) * **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)) * **rules:** we prefer release naming over production status ([b7c0cd0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/-/commit/b7c0cd0ef2f9cff3c0748f1d57927395013c153f))
...@@ -14,26 +14,26 @@ contribution to make sure everything can be integrated correctly. ...@@ -14,26 +14,26 @@ contribution to make sure everything can be integrated correctly.
In Gitlab, the [CI](https://docs.gitlab.com/ee/ci/) configuration is In Gitlab, the [CI](https://docs.gitlab.com/ee/ci/) configuration is
done in a file called done in a file called
[.gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html) [`.gitlab-ci.yml`](https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html)
in the root directory of the sources of a project. in the root directory of the sources of a project.
Every branches with that file could run some pipeline if configured. Every branches with that file could run some pipeline if configured.
We will see 5 main `.gitlab-ci.yml` concepts in this documentation: We will see 5 main `.gitlab-ci.yml` concepts in this documentation:
- the [rules](#rules) permit to include or exclude jobs in a pipeline, - the [`rules`](#rules) permit to include or exclude jobs in a
an empty pipeline does not run. pipeline, an empty pipeline does not run.
- the [stages](#stages) to group jobs together and define the order of - the [`stages`](#stages) to group jobs together and define the order
execution of the groups of execution of the groups
- [include](#include) to reuse configuration files across projects - [`include`](#include) to reuse configuration files across projects
- the [extends](#extends) to reuse configuration sections - the [`extends`](#extends) to reuse configuration sections
- the [jobs](#jobs) them-self to execute action in the pipeline. - the [`jobs`](#jobs) them-self to execute action in the pipeline.
### Rules ### Rules
Instead of defining again and again the Instead of defining again and again the
[rules](https://docs.gitlab.com/ee/ci/yaml/#rules) to apply to jobs, [`rules`](https://docs.gitlab.com/ee/ci/yaml/#rules) to apply to jobs,
we define a [common set of rules](templates/Rules.yaml) to be used we define a [common set of `rules`](templates/Rules.yaml) to be used
directly by jobs. directly by jobs.
For example, to make a job run only on the `dev` branch: For example, to make a job run only on the `dev` branch:
...@@ -41,7 +41,7 @@ For example, to make a job run only on the `dev` branch: ...@@ -41,7 +41,7 @@ For example, to make a job run only on the `dev` branch:
```yaml ```yaml
include: include:
# We include the definitions before using them # We include the definitions before using them
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Rules.yaml file: /templates/Rules.yaml
...@@ -51,23 +51,24 @@ run-only-on-dev: ...@@ -51,23 +51,24 @@ run-only-on-dev:
- echo "I'm running only on $DEV_BRANCH" - echo "I'm running only on $DEV_BRANCH"
``` ```
The [rules template](templates/Rules.yaml) define variables for the The [`rules` template](templates/Rules.yaml) define variables for the
default branch names: default branch names:
- `STABLE_BRANCH`: default to `stable` - `STABLE_BRANCH`: default to `stable`
- `DEV_BRANCH`: default to `dev`
- `TESTING_BRANCH`: default to `testing` - `TESTING_BRANCH`: default to `testing`
- `ALPHA_BRANCH`: default to `alpha`
- `DEV_BRANCH`: default to `dev`
### Stages ### Stages
The [stages](https://docs.gitlab.com/ee/ci/yaml/#stages) can be The [`stages`](https://docs.gitlab.com/ee/ci/yaml/#stages) can be
whatever you want, the `ci-tools` templates use 3 stages by default: whatever you want, the `ci-tools` templates use 3 stages by default:
- `lint` for [`commitlint`](#validate-commit-messages) - `lint` for [`.git:commitlint`](#validate-commit-messages)
- `build` for [`.build-docker-image`](#building-images) - `build` for [`.docker:image:build`](#building-images)
- `release` for - `release` for
[`semantic-release`](#generate-release-with-semantic-version-scheme) [`.semantic-release:stable`](#generate-release-with-semantic-version-scheme)
and [`.tag-docker-image`](#tagging-docker-images) and [`.docker:image:tag`](#tagging-docker-images)
The order of `stages` list is important, `lint` should come first, The order of `stages` list is important, `lint` should come first,
then `build` and finally `release` to publish the build results. then `build` and finally `release` to publish the build results.
...@@ -82,22 +83,24 @@ provides templates to be ...@@ -82,22 +83,24 @@ provides templates to be
```yaml ```yaml
include: include:
# We include the definitions before using them # We include the definitions before using them
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Rules.yaml file: /templates/Rules.yaml
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Lint/Commitlint.yaml file: /templates/Git.yaml
stages: stages:
- lint - lint
commitlint: {extends: '.git:commitlint'}
``` ```
### Extends ### Extends
The [extends](https://docs.gitlab.com/ee/ci/yaml/#extends) keyword The [extends](https://docs.gitlab.com/ee/ci/yaml/#extends) keyword
permits to merge different YAML jobs together, the most common case permits to merge different YAML jobs together, the most common case
use [hidden template uses [hidden template
jobs](https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html) (with jobs](https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html) (with
names starting by a dot `.`). names starting by a dot `.`).
...@@ -105,7 +108,7 @@ names starting by a dot `.`). ...@@ -105,7 +108,7 @@ names starting by a dot `.`).
.alpine-common: .alpine-common:
image: "$ALPINE_IMAGE" image: "$ALPINE_IMAGE"
variables: variables:
ALPINE_IMAGE: "hub.eole.education/proxyhub/library/alpine:latest" ALPINE_IMAGE: "alpine:latest"
FOO: "this is FOO in .alpine-common" FOO: "this is FOO in .alpine-common"
before_script: before_script:
- echo "I run before any other 'script'" - echo "I run before any other 'script'"
...@@ -131,11 +134,15 @@ Before using the CI tools templates, you must setup your repository. ...@@ -131,11 +134,15 @@ Before using the CI tools templates, you must setup your repository.
You must create the branches[^1] required to your release cycle: You must create the branches[^1] required to your release cycle:
1. create the `dev` branch and [set it as default](https://docs.gitlab.com/ee/user/project/repository/branches/default.html) 1. create the `dev` branch and [set it as default](https://docs.gitlab.com/ee/user/project/repository/branches/default.html)
2. create the `testing` branch if you want a staging area where to 2. create the `alpha` branch if you want a staging area where to
stabilise your project before release stabilise your project before release
3. create the `stable` branch where the releases are kept if you don't want to keep the default name (`master` or `main` depending of the configuration of your Gitlab) 3. create the `stable` branch where the releases are kept if you don't
want to keep the default name (`main`, `stable` or `master` depending of the configuration of your Gitlab)
[^1]: The branch names can be configured by setting the `DEV_BRANCH`, `TESTING_BRANCH` and `STABLE_BRANCH` variables in your own [.gitlab-ci.yml](https://docs.gitlab.com/ee/ci/variables/#create-a-custom-cicd-variable-in-the-gitlab-ciyml-file) [^1]: The branch names can be configured by setting the `DEV_BRANCH`,
`ALPHA_BRANCH`, `TESTING_BRANCH` and `STABLE_BRANCH` variables in
your own
[.gitlab-ci.yml](https://docs.gitlab.com/ee/ci/variables/#create-a-custom-cicd-variable-in-the-gitlab-ciyml-file)
### Protect your release cycle branches and tags ### Protect your release cycle branches and tags
...@@ -152,9 +159,9 @@ or `Developpers + Maintainers`. ...@@ -152,9 +159,9 @@ or `Developpers + Maintainers`.
Finally, you must [protect the release tag Finally, you must [protect the release tag
pattern](https://docs.gitlab.com/ee/user/project/protected_tags.html) pattern](https://docs.gitlab.com/ee/user/project/protected_tags.html)
`release/*` with only push allowed for `Maintainers` used by `release/` with only push allowed for `Maintainers` used by
`semantic-release`. That's the reason why the [release tag `semantic-release`. That's the reason why the [release tag
rules](templates/Rules.yaml#L154) run only on protected tags. rules](templates/Rules.yaml#L168-170) run only on protected tags.
### Create the `GITLAB_TOKEN` access token ### Create the `GITLAB_TOKEN` access token
...@@ -215,18 +222,19 @@ you need mostly 4 steps: ...@@ -215,18 +222,19 @@ you need mostly 4 steps:
# vim: ft=yaml # vim: ft=yaml
--- ---
include: include:
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Rules.yaml file: /templates/Rules.yaml
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Lint/Commitlint.yaml file: /templates/Git.yaml
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Docker.yaml file: /templates/Semantic-release.yaml
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Release/Semantic-release.yaml file: /templates/Docker.yaml
stages: stages:
- initial-checks - initial-checks
...@@ -236,8 +244,10 @@ you need mostly 4 steps: ...@@ -236,8 +244,10 @@ you need mostly 4 steps:
- release - release
variables: variables:
# Globally defined docker image name
IMAGE_NAME: useless IMAGE_NAME: useless
############################################################################### ###############################################################################
# `initial-checks` stage: `has-dev-branch`, `has-testing-branch`, `has-stable-branch` # `initial-checks` stage: `has-dev-branch`, `has-testing-branch`, `has-stable-branch`
############################################################################### ###############################################################################
...@@ -248,7 +258,7 @@ you need mostly 4 steps: ...@@ -248,7 +258,7 @@ you need mostly 4 steps:
variables: variables:
TARGET_BRANCH: $DEV_BRANCH TARGET_BRANCH: $DEV_BRANCH
# We use whatever image that has git # We use whatever image that has git
image: 'hub.eole.education/eole/commitlint:latest' image: 'bitnami/git:latest'
script: script:
- echo -e "\e[0Ksection_start:`date +%s`:has_branch[collapsed=true]\r\e[0KCheck that '${TARGET_BRANCH}' branch exists upstream" - echo -e "\e[0Ksection_start:`date +%s`:has_branch[collapsed=true]\r\e[0KCheck that '${TARGET_BRANCH}' branch exists upstream"
- 'git fetch --all' - 'git fetch --all'
...@@ -268,53 +278,79 @@ you need mostly 4 steps: ...@@ -268,53 +278,79 @@ you need mostly 4 steps:
variables: variables:
TARGET_BRANCH: $STABLE_BRANCH TARGET_BRANCH: $STABLE_BRANCH
############################################################################### ###############################################################################
# `lint` stage: `commitlint` # `lint` stage: `commitlint`
############################################################################### ###############################################################################
# the `commitlint` is defined in `templates/Lint/Commitlint.yaml` included before commitlint: {extends: '.git:commitlint'}
############################################################################### ###############################################################################
# `build` stage: `build-docker` # `build` stage: `build-docker`
############################################################################### ###############################################################################
# The name of the built image is define globally by `$IMAGE_NAME` # The name of the built image is define globally by `$IMAGE_NAME`
# The build is done:
# - for contribution branches
# - for `$DEV_BRANCH`
# - on release tags (stable and testing) after the application
# versions are updated by `semantic-release`
.build-docker-rules:
rules:
# The ordering is CRITICAL
- !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, not-on-stable]
- !reference [.rules-map, not-on-testing]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branches]
build-docker: build-docker:
extends: .build-docker-image extends:
- .docker:image:build
- .build-docker-rules
############################################################################### ###############################################################################
# `test` stage: `useless-test` # `test` stage: `useless-test`
############################################################################### ###############################################################################
useless-test: useless-test:
stage: test stage: test
extends: .not-on-stable # Use the previously built image, so reuse the same `rules`
# Use the previously built image extends: .build-docker-rules
image: "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:git-${CI_COMMIT_SHORT_SHA}" image: "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:git-${CI_COMMIT_SHORT_SHA}"
script: script:
- echo "I successfully ran in ${IMAGE_NAME}:git-${CI_COMMIT_SHORT_SHA}" - echo "I successfully ran in ${IMAGE_NAME}:git-${CI_COMMIT_SHORT_SHA}"
############################################################################### ###############################################################################
# `release` stage: `semantic-release`, `merge-to-dev`, `tag *` # `release` stage: `semantic-release`, `testing-prerelease`,
# `merge-to-dev`, `tag *`
############################################################################### ###############################################################################
# Avoid regression by merging all pre-release fixes to dev # Create the release versions on `$STABLEE_BRANCH`
merge-to-dev: new-release: {extends: '.semantic-release:stable'}
stage: release
extends: .on-release-tag # Create the prereleases versions on `$TESTING_BRANCH`
# We use whatever image that has git # update `.releaserc.js` variable `betaBranch`
image: 'hub.eole.education/eole/commitlint:latest' testing-prerelease: {extends: '.semantic-release:testing'}
script:
# Add `upstream` remote to push with `write_repository` token # Avoid regression by merging all pre-release fixes to `$DEV_BRANCH`
# Use `${GITLAB_TOKEN}` for write permission merge-to-dev: {extends: '.git:merge-to', variables: {GIT_MERGE_TARGET: $DEV_BRANCH}}
- "git remote show upstream 2> /dev/null || git remote add upstream ${CI_REPOSITORY_URL/${CI_JOB_TOKEN}/${GITLAB_TOKEN}}"
- 'git fetch --all' ## tag contribution branches with a more stable name than `git-${CI_COMMIT_SHORT_SHA}`
- 'git checkout -b ${DEV_BRANCH} upstream/${DEV_BRANCH}' tag contrib branch:
- 'git merge --no-edit ${CI_COMMIT_TAG}' extends:
- 'git push upstream ${DEV_BRANCH}' - .docker:image:tag
# Remove `upstream` to avoid caching `CI_JOB_TOKEN` - .on-branches
- "git remote remove upstream" variables:
# `feature/foo-bar_quux` → `feature-foo-bar-quux`
IMAGE_TAG: $CI_COMMIT_REF_SLUG
## dev images ## dev images
tag dev: tag dev:
extends: extends:
- .tag-docker-image - .docker:image:tag
- .on-dev - .on-dev
variables: variables:
IMAGE_TAG: dev IMAGE_TAG: dev
...@@ -322,25 +358,20 @@ you need mostly 4 steps: ...@@ -322,25 +358,20 @@ you need mostly 4 steps:
## testing images ## testing images
tag testing: tag testing:
extends: extends:
- .tag-docker-image - .docker:image:tag
- .on-testing # After `semantic-release`
- .on-testing-tag
variables: variables:
IMAGE_TAG: testing IMAGE_TAG: testing
## stable images ## stable images
# we retag the latest `testing`
.tag-stable:
extends: .tag-docker-image
variables:
SOURCE_TAG: "testing"
# add the `X.Y.Z` tag # add the `X.Y.Z` tag
tag release: tag release:
extends: .tag-stable extends: .docker:image:tag
# add the `X` tag # add the `X` tag
tag major: tag major:
extends: .tag-stable extends: .docker:image:tag
before_script: before_script:
- export RELEASE_PREFIX=${RELEASE_PREFIX:-release/} - export RELEASE_PREFIX=${RELEASE_PREFIX:-release/}
- export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}} - export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}}
...@@ -348,31 +379,30 @@ you need mostly 4 steps: ...@@ -348,31 +379,30 @@ you need mostly 4 steps:
# add the `X.Y` tag # add the `X.Y` tag
tag minor: tag minor:
extends: extends: .docker:image:tag
- .tag-stable
before_script: before_script:
- export RELEASE_PREFIX=${RELEASE_PREFIX:-release/} - export RELEASE_PREFIX=${RELEASE_PREFIX:-release/}
- export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}} - export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}}
- export IMAGE_TAG=${RELEASE%.${RELEASE##*.}} - export IMAGE_TAG=${RELEASE%.${RELEASE##*.}}
tag stable: tag stable:
extends: .tag-stable extends: .docker:image:tag
variables: variables:
IMAGE_TAG: stable IMAGE_TAG: stable
tag latest: tag latest:
extends: .tag-stable extends: .docker:image:tag
variables: variables:
IMAGE_TAG: latest IMAGE_TAG: latest
...
``` ```
</details> </details>
2. configure [`commitlint`](#validate-commit-messages) with the [`commitlint.config.js`](commitlint.config.js) 2. configure [`commitlint`](#validate-commit-messages) with the
3. configure [`semantic-release`](#generate-release-with-semantic-version-scheme) [`.commitlintrc.yaml`](.commitlintrc.yaml)
1. the general configuration 3. configure
[`release.config.js`](release.config.js) (note that the [`semantic-release`](#generate-release-with-semantic-version-scheme)
`branches` variable must match your `$STABLE_BRANCH`) in [`.releaserc.js`](.releaserc.js) (note that the `branches` variable must match your `$STABLE_BRANCH`)
2. the version bump rules in [`release-rules.js`](release-rules.js) 4. add a `Dockerfile` in the root directory of your sources
3. add a `Dockerfile` in the root directory of your sources
### Step by step setup ### Step by step setup
...@@ -391,6 +421,7 @@ itself except providing: ...@@ -391,6 +421,7 @@ itself except providing:
- the default branch names variables - the default branch names variables
- `$STABLE_BRANCH` defaults to `stable` - `$STABLE_BRANCH` defaults to `stable`
- `$TESTING_BRANCH` defaults to `testing` - `$TESTING_BRANCH` defaults to `testing`
- `$ALPHA_BRANCH` defaults to `alpha`
- `$DEV_BRANCH` defaults to `dev` - `$DEV_BRANCH` defaults to `dev`
- several [hidden template - several [hidden template
jobs](https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html) to jobs](https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html) to
...@@ -401,21 +432,22 @@ itself except providing: ...@@ -401,21 +432,22 @@ itself except providing:
To use it, just include it at the top level of your `.gitlab-ci.yml`: To use it, just include it at the top level of your `.gitlab-ci.yml`:
```diff ```diff
--- .gitlab-ci.yml.orig 2021-12-14 11:42:36.631152773 +0100 --- .gitlab-ci.yml.orig
+++ .gitlab-ci.yml 2021-12-14 11:42:13.039315046 +0100 +++ .gitlab-ci.yml
@@ -1,3 +1,7 @@ @@ -1,4 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
+include: +include:
+ - project: EOLE/infra/ci-tools + - project: EOLE/Infra/ci-tools
+ ref: stable + ref: stable
+ file: /templates/Rules.yaml + file: /templates/Rules.yaml
...
``` ```
If the rules definition is too limited for your use case, you can If the rules definition is too limited for your use case, you can
combine the raw conditions to extend them like in combine the raw conditions to extend them like in
[`templates/Release/Semantic-release.yaml`](templates/Release/Semantic-release.yaml) [`templates/Semantic-release.yaml`](templates/Semantic-release.yaml)
You can read [`templates/Rules.yaml`](templates/Rules.yaml) for the You can read [`templates/Rules.yaml`](templates/Rules.yaml) for the
complete list of usable rules templates. complete list of usable rules templates.
...@@ -427,35 +459,39 @@ documentation](docs/CONTRIBUTING.md), the commit message formatting is ...@@ -427,35 +459,39 @@ documentation](docs/CONTRIBUTING.md), the commit message formatting is
important to generate release automatically with important to generate release automatically with
[`semantic-release`](#generate-release-with-semantic-version-scheme). [`semantic-release`](#generate-release-with-semantic-version-scheme).
To ensure that all the commits are correctly formatted, you just need To ensure that all the commits are correctly formatted, you just need to:
to:
1. the `.not-on-stable` rules template provided by the 1. include [`templates/Rules.yaml`](#target-when-to-run-jobs) file to
[rules](#target-when-to-run-jobs) template define the `.not-on-stable` rules templates
2. include the 2. include the [`templates/Git.yaml`](templates/Git.yaml) file
[`templates/Lint/Commitlint.yaml`](templates/Lint/Commitlint.yaml) 3. be sure to have the `lint` stage to your current `stages` in your
3. be sure to have the `lint` to your current `stages` in your `.gitlab-ci.yml` `.gitlab-ci.yml`
4. configure `commitlint` by creating the [`commitlint.config.js`](commitlint.config.js) in 4. define the `commitlint` job extending [`.git:commitlint`](templates/Git.yaml#L11-L85)
the root of your repository 5. configure `commitlint` by creating the
[`.commitlintrc.yaml`](.commitlintrc.yaml) in the root of your
repository
```diff ```diff
--- .gitlab-ci.yml.orig 2021-12-14 11:47:56.645304805 +0100 --- .gitlab-ci.yml.orig
+++ .gitlab-ci.yml 2021-12-14 11:47:36.277406568 +0100 +++ .gitlab-ci.yml
@@ -5,3 +5,14 @@ @@ -5,4 +5,17 @@
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Rules.yaml file: /templates/Rules.yaml
+ - project: EOLE/infra/ci-tools + - project: EOLE/Infra/ci-tools
+ ref: stable + ref: stable
+ file: /templates/Lint/Commitlint.yaml + file: /templates/Git.yaml
+
+ +
+stages: +stages:
+ - lint + - lint
+ +
+
+############################################################################### +###############################################################################
+# `lint` stage: `commitlint` +# `lint` stage: `commitlint`
+############################################################################### +###############################################################################
+# the `commitlint` is defined in `templates/Lint/Commitlint.yaml` +commitlint: {extends: '.git:commitlint'}
...
``` ```
#### Generate release with semantic version scheme #### Generate release with semantic version scheme
...@@ -463,42 +499,51 @@ to: ...@@ -463,42 +499,51 @@ to:
Before enabling the automatic release creation, you should enable [`commitlint`](#Validate-commit-messages). Before enabling the automatic release creation, you should enable [`commitlint`](#Validate-commit-messages).
To setup [`semantic-release`](https://github.com/semantic-release/), To setup [`semantic-release`](https://github.com/semantic-release/),
you need: you need to:
1. the `.not-on-stable` rules template provided by the 1. include [`templates/Rules.yaml`](#target-when-to-run-jobs) file to
[rules](#target-when-to-run-jobs) template define the `.on-stable` and `.on-testing` rules template
2. include the 2. include the
[`templates/Release/Semantic-release.yaml`](templates/Release/Semantic-release.yaml) [`templates/Semantic-release.yaml`](templates/Semantic-release.yaml) file
3. be sure to have the `release` stage to your current `stages` in your `.gitlab-ci.yml` 3. be sure to have the `release` stage to your current `stages` in
4. configure `semantic-release`: your `.gitlab-ci.yml`
1. [`release.config.js`](release.config.js) 4. define the `new-release` job extending [`.semantic-release:stable`](templates/Semantic-release.yaml#L17-L81)
2. [`release-rules.js`](release-rules.js) 5. define the `testing-prerelease` job extending [`.semantic-release:testing`](templates/Semantic-release.yaml#L84-L144)
6. configure `semantic-release` in [`.releaserc.js`](.releaserc.js)
```diff ```diff
--- .gitlab-ci.yml.orig 2021-12-14 11:51:49.984245841 +0100 --- .gitlab-ci.yml.orig
+++ .gitlab-ci.yml 2021-12-14 11:51:29.196333335 +0100 +++ .gitlab-ci.yml
@@ -8,11 +8,21 @@ @@ -8,14 +8,29 @@
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Lint/Commitlint.yaml file: /templates/Git.yaml
+ - project: EOLE/infra/ci-tools + - project: EOLE/Infra/ci-tools
+ ref: stable + ref: stable
+ file: /templates/Release/Semantic-release.yaml + file: /templates/Semantic-release.yaml
stages: stages:
- lint - lint
+ - release + - release
############################################################################### ###############################################################################
# `lint` stage: `commitlint` # `lint` stage: `commitlint`
############################################################################### ###############################################################################
# the `commitlint` is defined in `templates/Lint/Commitlint.yaml` commitlint: {extends: '.git:commitlint'}
+ +
+ +
+############################################################################### +###############################################################################
+# `release` stage: `semantic-release` +# `release` stage: `new-release`, `testing-prerelease`
+############################################################################### +###############################################################################
+# the `semantic-release` is defined in `templates/Release/Semantic-Release.yaml` +# Create the release versions on `$STABLEE_BRANCH`
+new-release: {extends: '.semantic-release:stable'}
+
+# Create the prereleases versions on `$TESTING_BRANCH`
+# update `.releaserc.js` variable `betaBranch`
+testing-prerelease: {extends: '.semantic-release:testing'}
...
``` ```
#### Build and tag docker images #### Build and tag docker images
...@@ -509,7 +554,7 @@ templates to build and tag docker images. ...@@ -509,7 +554,7 @@ templates to build and tag docker images.
##### Building images ##### Building images
The [`templates/Docker.yaml`](templates/Docker.yaml) defines The [`templates/Docker.yaml`](templates/Docker.yaml) defines
[`.build-docker-image`](templates/Docker.yaml#L4-54) job template [`.docker:image:build`](templates/Docker.yaml#L11-L84) job template
which, by default, build the container image and push it to which, by default, build the container image and push it to
`${CI_REGISTRY}` for all branches except `$STABLE_BRANCH`. `${CI_REGISTRY}` for all branches except `$STABLE_BRANCH`.
...@@ -519,23 +564,24 @@ does not require to enable docker-in-docker privileged mode. ...@@ -519,23 +564,24 @@ does not require to enable docker-in-docker privileged mode.
The simplest use of this template require 4 elements: The simplest use of this template require 4 elements:
1. the `.not-on-stable` rules template provided by the 1. include [`templates/Rules.yaml`](#target-when-to-run-jobs) file to
[rules](#target-when-to-run-jobs) template define the `.not-on-stable` and `.on-release-tag` rules template
2. include the [`templates/Docker.yaml`](templates/Docker.yaml) template 2. include the [`templates/Docker.yaml`](templates/Docker.yaml) template
3. be sure to have the `build` stage to your current `stages` in your `.gitlab-ci.yml` 3. be sure to have the `build` stage to your current `stages` in your `.gitlab-ci.yml`
4. extends the `.build-docker-image` template to define the build job 4. extends the [`.docker:image:build`](templates/Docker.yaml#L11-L84) template to define the build job
```diff ```diff
--- .gitlab-ci.yml.orig 2021-12-14 11:53:19.627880842 +0100 --- .gitlab-ci.yml.orig
+++ .gitlab-ci.yml 2021-12-14 11:54:50.483528896 +0100 +++ .gitlab-ci.yml
@@ -11,11 +11,19 @@ @@ -11,12 +11,20 @@
- project: EOLE/infra/ci-tools - project: EOLE/Infra/ci-tools
ref: stable ref: stable
file: /templates/Release/Semantic-release.yaml file: /templates/Semantic-release.yaml
+ - project: EOLE/infra/ci-tools + - project: EOLE/Infra/ci-tools
+ ref: stable + ref: stable
+ file: /templates/Docker.yaml + file: /templates/Docker.yaml
stages: stages:
- lint - lint
+ - build + - build
...@@ -545,30 +591,50 @@ The simplest use of this template require 4 elements: ...@@ -545,30 +591,50 @@ The simplest use of this template require 4 elements:
+ # Globally defined docker image name + # Globally defined docker image name
+ IMAGE_NAME: useless + IMAGE_NAME: useless
+ +
############################################################################### ###############################################################################
# `lint` stage: `commitlint` # `lint` stage: `commitlint`
############################################################################### @@ -24,6 +32,33 @@
@@ -23,6 +31,14 @@ commitlint: {extends: '.git:commitlint'}
############################################################################### +###############################################################################
+# `build` stage: `build-docker` +# `build` stage: `build-docker`
+############################################################################### +###############################################################################
+# The name of the built image is define globally by `$IMAGE_NAME` +# The name of the built image is define globally by `$IMAGE_NAME`
+# The build is done:
+# - for contribution branches
+# - for `$DEV_BRANCH`
+# - on release tags (stable and testing) after the application
+# versions are updated by `semantic-release`
+.build-docker-rules:
+ rules:
+ # The ordering is CRITICAL
+ - !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, not-on-stable]
+ - !reference [.rules-map, not-on-testing]
+ - !reference [.rules-map, not-on-semantic-release-commit]
+ - !reference [.rules-map, on-branch]
+
+build-docker: +build-docker:
+ extends: .build-docker-image + extends:
+ - .docker:image:build
+ - .build-docker-rules
+ +
+ +
+###############################################################################
# `release` stage: `semantic-release`
############################################################################### ###############################################################################
# the `semantic-release` is defined in `templates/Release/Semantic-Release.yaml` # `release` stage: `new-release`, `testing-prerelease`
###############################################################################
``` ```
##### Tagging docker images ##### Tagging docker images
By default, the [`.tag-docker-image`](templates/Docker.yaml#L56-104) job template works on the release By default, the [`.docker:image:tag`](templates/Docker.yaml#L92-L161)
tag only to create the docker tag `X.Y.Z`. job template works on the release tag only to create the docker tag
`X.Y.Z`.
In a typical release cycle, you want to create the following tags: In a typical release cycle, you want to create the following tags:
...@@ -584,33 +650,38 @@ In a typical release cycle, you want to create the following tags: ...@@ -584,33 +650,38 @@ In a typical release cycle, you want to create the following tags:
- `release` tag with the full semantic version - `release` tag with the full semantic version
- `latest`/`stable` point to the latest stable image - `latest`/`stable` point to the latest stable image
To be used, you need: To be used, you need to:
1. the `.not-on-stable` rules template provided by the 1. include [`templates/Rules.yaml`](#target-when-to-run-jobs) file to
[rules](#target-when-to-run-jobs) template define the rules template
2. include the [`templates/Docker.yaml`](templates/Docker.yaml) 2. include the [`templates/Docker.yaml`](templates/Docker.yaml)
template template
1. be sure to have the `release` stage to your current `stages` in 1. be sure to have the `release` stage to your current `stages` in
your `.gitlab-ci.yml` your `.gitlab-ci.yml`
2. extends the `.tag-docker-image` template to create as many tagging 2. extends the [`.docker:image:tag`](templates/Docker.yaml#L92-L161) template to create as many tagging
jobs as required for your release cycle jobs as required for your release cycle
```diff ```diff
--- .gitlab-ci.yml.orig 2021-12-14 11:58:55.434649075 +0100 --- .gitlab-ci.yml.orig
+++ .gitlab-ci.yml 2021-12-14 12:00:21.410358359 +0100 +++ .gitlab-ci.yml
@@ -39,6 +39,69 @@ @@ -60,7 +60,7 @@
############################################################################### ###############################################################################
-# `release` stage: `semantic-release` -# `release` stage: `semantic-release`, `testing-prerelease`
+# `release` stage: `semantic-release`, `tag *` +# `release` stage: `semantic-release`, `testing-prerelease`, `tag *`
############################################################################### ###############################################################################
# the `semantic-release` is defined in `templates/Release/Semantic-Release.yaml` # Create the release versions on `$STABLEE_BRANCH`
new-release: {extends: '.semantic-release:stable'}
@@ -68,4 +68,61 @@
# Create the prereleases versions on `$TESTING_BRANCH`
# update `.releaserc.js` variable `betaBranch`
testing-prerelease: {extends: '.semantic-release:testing}
+ +
+## tag contribution branches with a more stable name than `git-${CI_COMMIT_SHORT_SHA}` +## tag contribution branches with a more stable name than `git-${CI_COMMIT_SHORT_SHA}`
+tag contrib branch: +tag contrib branch:
+ extends: + extends:
+ - .tag-docker-image + - .docker:image:tag
+ - .on-branches + - .on-branches
+ variables: + variables:
+ # `feature/foo-bar_quux` → `feature-foo-bar-quux` + # `feature/foo-bar_quux` → `feature-foo-bar-quux`
...@@ -619,7 +690,7 @@ To be used, you need: ...@@ -619,7 +690,7 @@ To be used, you need:
+## dev images +## dev images
+tag dev: +tag dev:
+ extends: + extends:
+ - .tag-docker-image + - .docker:image:tag
+ - .on-dev + - .on-dev
+ variables: + variables:
+ IMAGE_TAG: dev + IMAGE_TAG: dev
...@@ -627,25 +698,20 @@ To be used, you need: ...@@ -627,25 +698,20 @@ To be used, you need:
+## testing images +## testing images
+tag testing: +tag testing:
+ extends: + extends:
+ - .tag-docker-image + - .docker:image:tag
+ - .on-testing + # After `semantic-release`
+ - .on-testing-tag
+ variables: + variables:
+ IMAGE_TAG: testing + IMAGE_TAG: testing
+ +
+## stable images +## stable images
+# we retag the latest `testing`
+.tag-stable:
+ extends: .tag-docker-image
+ variables:
+ SOURCE_TAG: "testing"
+
+# add the `X.Y.Z` tag +# add the `X.Y.Z` tag
+tag release: +tag release:
+ extends: .tag-stable + extends: .docker:image:tag
+ +
+# add the `X` tag +# add the `X` tag
+tag major: +tag major:
+ extends: .tag-stable + extends: .docker:image:tag
+ before_script: + before_script:
+ - export RELEASE_PREFIX=${RELEASE_PREFIX:-release/} + - export RELEASE_PREFIX=${RELEASE_PREFIX:-release/}
+ - export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}} + - export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}}
...@@ -653,31 +719,63 @@ To be used, you need: ...@@ -653,31 +719,63 @@ To be used, you need:
+ +
+# add the `X.Y` tag +# add the `X.Y` tag
+tag minor: +tag minor:
+ extends: + extends: .docker:image:tag
+ - .tag-stable
+ before_script: + before_script:
+ - export RELEASE_PREFIX=${RELEASE_PREFIX:-release/} + - export RELEASE_PREFIX=${RELEASE_PREFIX:-release/}
+ - export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}} + - export RELEASE=${CI_COMMIT_TAG#${RELEASE_PREFIX}}
+ - export IMAGE_TAG=${RELEASE%.${RELEASE##*.}} + - export IMAGE_TAG=${RELEASE%.${RELEASE##*.}}
+ +
+tag stable: +tag stable:
+ extends: .tag-stable + extends: .docker:image:tag
+ variables: + variables:
+ IMAGE_TAG: stable + IMAGE_TAG: stable
+ +
+tag latest: +tag latest:
+ extends: .tag-stable + extends: .docker:image:tag
+ variables: + variables:
+ IMAGE_TAG: latest + IMAGE_TAG: latest
...
``` ```
#### Select the runner to run the CI pipelines #### Avoid regression after stable release
When the next release is prepared in the `$TESTING_BRANCH`, any fixes
should be applied to the `$DEV_BRANCH` to avoid regressions.
Selecting CI runners is done with tags like done globally in You can either manually merge the fixes to `$DEV_BRANCH` or use the
[`templates/Runners/eole-docker.yaml`](templates/Runners/eole-docker.yaml) `.git:merge-to` template job to automatically merge the release tag to
or the `$DEV_BRANCH`.
[`templates/Runners/apps.education-docker.yaml`](templates/Runners/apps.education-docker.yaml)
using the [`default:tags`](https://docs.gitlab.com/ee/ci/yaml/#tags)
in your own `.gitlab-ci.yml`.
To do so, you need to:
1. include [`templates/Rules.yaml`](#target-when-to-run-jobs) file to
define the `.not-on-stable` rules template
2. include the [`templates/Git.yaml`](templates/Git.yaml) file
3. be sure to have the `release` stage to your current `stages` in
your `.gitlab-ci.yml`
4. define the `merge-to-dev` job extending [`.git:merge-to`](templates/Git.yaml#L88-L185)
```diff
--- .gitlab-ci.yaml.orig
+++ .gitlab-ci.yaml
@@ -60,7 +60,8 @@
###############################################################################
-# `release` stage: `semantic-release`, `testing-prerelease`, `tag *`
+# `release` stage: `semantic-release`, `testing-prerelease`,
+# `merge-to-dev`, `tag *`
###############################################################################
# Create the release versions on `$STABLEE_BRANCH`
new-release: {extends: '.semantic-release:stable'}
@@ -69,6 +70,9 @@
# update `.releaserc.js` variable `betaBranch`
testing-prerelease: {extends: '.semantic-release:testing}
+# Avoid regression by merging all pre-release fixes to `$DEV_BRANCH`
+merge-to-dev: {extends: '.git:merge-to', variables: {GIT_MERGE_TARGET: $DEV_BRANCH}}
+
## tag contribution branches with a more stable name than `git-${CI_COMMIT_SHORT_SHA}`
tag contrib branch:
extends:
```
// 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' },
];
# -*- mode: yaml; coding: utf-8 -*- # -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
# #
# Define `.build-docker-image` template used by `*-docker-build` jobs # Hidden template jobs to be used in `.gitlab-ci.yml`
# It build the container image and push it to `${CI_REGISTRY}` #
# - `.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 # USAGE
# ===== # =====
# #
# foo-docker-build: # foo-docker-build:
# extends: .build-docker-image # extends: .docker:image:build
# variables: # variables:
# DOCKERFILE: Some-specific.Dockerfile # DOCKERFILE: Some-specific.Dockerfile
# IMAGE_TAG: $CI_COMMIT_REF_SLUG # IMAGE_TAG: $CI_COMMIT_REF_SLUG
...@@ -16,92 +26,142 @@ ...@@ -16,92 +26,142 @@
# REQUIREMENTS # 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. # overriden by the extending job to feet your need.
# - The `.not-on-stable` rules template #
# - the `.not-on-stable` rules templates
# #
# OPTIONAL VARIABLES # 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 # - `DOCKERFILE`: defaults, in order
# - to value set by the user # - to value set by the user
# - to `Dockerfile.${IMAGE_NAME}` if the file exists # - to `Dockerfile.${IMAGE_NAME}` if the file exists
# - to `Dockerfile` if the file exists # - to `Dockerfile` if the file exists
# - `IMAGE_TAG`: defaults to `git-${CI_COMMIT_SHORT_SHA}` #
# - `KANIKO_ARGS`: arguments to pass to kaniko executor command, empty by default # - `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 # USED CI VARIABLES
# ================= # =================
# #
# - `CI_REGISTRY` # - `CI_REGISTRY`
#
# - `CI_REGISTRY_USER` # - `CI_REGISTRY_USER`
#
# - `CI_REGISTRY_PASSWORD` # - `CI_REGISTRY_PASSWORD`
#
# - `CI_REGISTRY_IMAGE` # - `CI_REGISTRY_IMAGE`
# #
.build-docker-image: .docker:image:build:
stage: build stage: build
extends: .not-on-stable extends: .not-on-stable
image: image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug name: "${KANIKO_IMAGE}"
entrypoint: [""] entrypoint: [""]
variables: variables:
KANIKO_IMAGE: gcr.io/kaniko-project/executor:v1.7.0-debug
KANIKO_ARGS: '' KANIKO_ARGS: ''
script: 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*}} - 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.${IMAGE_NAME} && export DOCKERFILE=${DOCKERFILE:-Dockerfile.${IMAGE_NAME}} || true
- test -f Dockerfile && export DOCKERFILE=${DOCKERFILE:-Dockerfile} || true - test -f Dockerfile && export DOCKERFILE=${DOCKERFILE:-Dockerfile} || true
- export IMAGE_TAG=${IMAGE_TAG:-git-${CI_COMMIT_SHORT_SHA}} - export IMAGE_TAG=${IMAGE_TAG:-git-${CI_COMMIT_SHORT_SHA}}
- mkdir -p /kaniko/.docker - 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 - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- 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} - /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 # USAGE
# ===== # =====
# #
# foo-docker-tag-devel: # foo-docker-tag-devel:
# extends: .tag-docker-image # extends: .docker:image:tag
# variables: # variables:
# IMAGE_TAG: 'devel' # IMAGE_TAG: 'devel'
# #
# REQUIREMENTS # 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. # overriden by the extending job to feet your need.
# - The `.not-on-stable` rules template #
# - the `.on-release-tag` rules templates
# #
# OPTIONAL VARIABLES # OPTIONAL VARIABLES
# ================== # ==================
# #
# - `IMAGE_NAME`: defaults to `${CI_JOB_NAME}` with any suffix `-docker-tag*` removed # - `IMAGE_NAME`: name of the docker image to tag, defaults to
# - `SOURCE_TAG`: source image tag to retag, defaults to `git-${CI_COMMIT_SHORT_SHA}` # `CI_JOB_NAME` with any suffix `-docker-tag*` removed
# - `IMAGE_TAG`: image tag, defaults to `${CI_COMMIT_TAG}` with prefix `RELEASE_PREFIX` removed #
# - `RELEASE_PREFIX`: prefix of the `RELEASE`, defaults to `release/` # - `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 # USED CI VARIABLES
# ================= # =================
# #
# - `CI_REGISTRY` # - `CI_REGISTRY`
#
# - `CI_REGISTRY_USER` # - `CI_REGISTRY_USER`
#
# - `CI_REGISTRY_PASSWORD` # - `CI_REGISTRY_PASSWORD`
#
# - `CI_REGISTRY_IMAGE` # - `CI_REGISTRY_IMAGE`
# #
.tag-docker-image: .docker:image:tag:
stage: release stage: release
extends: .on-release-tag extends: .on-release-tag
image: image:
name: gcr.io/go-containerregistry/crane:debug name: "${CRANE_IMAGE}"
entrypoint: [""] entrypoint: [""]
variables: variables:
CRANE_IMAGE: gcr.io/go-containerregistry/crane:debug
GIT_STRATEGY: none GIT_STRATEGY: none
script: script:
- export IMAGE_NAME=${IMAGE_NAME:-${CI_JOB_NAME%-docker-tag*}} - echo -e "\e[0Ksection_start:`date +%s`:docker-image-tag-config[collapsed=true]\r\e[0KPrepare environment to tag docker image"
- export SOURCE_TAG=${SOURCE_TAG:-git-${CI_COMMIT_SHORT_SHA}} - export IMAGE_NAME="${IMAGE_NAME:-${CI_JOB_NAME%-docker-tag*}}"
- export RELEASE_PREFIX=${RELEASE_PREFIX:-release/} - export SOURCE_TAG="${SOURCE_TAG:-git-${CI_COMMIT_SHORT_SHA}}"
- export IMAGE_TAG=${IMAGE_TAG:-${CI_COMMIT_TAG#${RELEASE_PREFIX}}} - export RELEASE_TAG_PREFIX="${RELEASE_TAG_PREFIX:-release/}"
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - export IMAGE_TAG="${IMAGE_TAG:-${CI_COMMIT_TAG#${RELEASE_TAG_PREFIX}}}"
- crane tag ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${SOURCE_TAG} ${IMAGE_TAG} - 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 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
# #
# Verify formatting of all commit messages in the range # Backward compatible template.
# `$BASE_BRANCH..$CI_COMMIT_SHA`. # Use `templates/Git.yaml` instead
#
# USAGE
# =====
#
# include:
# - project: EOLE/infra/ci-tools
# ref: stable
# file: /templates/Rules.yaml
# - project: EOLE/infra/ci-tools
# ref: stable
# file: /templates/Lint/Commitlint.yaml
#
# stages:
# - lint
#
# OPTIONAL VARIABLES
# ==================
#
# - `BASE_BRANCH`: name of the referrence branch, defaults to
# `${CI_DEFAULT_BRANCH}`
# - `COMMITLINT_IMAGE`: name of the `commitlint` docker image to use
#
# REQUIREMENTS
# ============
#
# - The `.not-on-stable` rules template
# - A `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
#
# USED CI VARIABLES
# =================
#
# - `CI_COMMIT_SHA`
# - `CI_DEFAULT_BRANCH`
# - `CI_REPOSITORY_URL`
# #
--- ---
commitlint: include:
stage: lint local: /templates/Git.yaml
extends: .not-on-stable
image: "$COMMITLINT_IMAGE" commitlint: {extends: '.git:commitlint'}
variables:
COMMITLINT_IMAGE: 'hub.eole.education/eole/commitlint:latest' deprecation-commitlint:
BASE_BRANCH: "${CI_DEFAULT_BRANCH}" # Execute at the same time
extends: commitlint
# The failure must be a warning
allow_failure: true
script: script:
- 'git fetch --all' - 'echo "DEPRECATION WARNING: replace commitlint by .git:commitlint"'
# Set default commit hashes for `--from` and `--to` - 'echo "DEPRECATION WARNING: see /templates/Git.yaml"'
- 'export COMMITLINT_FROM="$(git merge-base origin/${BASE_BRANCH} HEAD)"' # Be visible in the CI pipeline
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"' - '/bin/false'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
... ...
# -*- 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 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # 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
# ==================
#
# - `SEMANTIC_RELEASE_IMAGE`: name of the `semantic-release` docker
# image to use
# #
# SEE ALSO # Backward compatible template.
# ======== # Use `templates/Semantic-release.yaml` instead
# #
# - Semantic release software: https://github.com/semantic-release/semantic-release/ ---
# - Commitlint: https://github.com/conventional-changelog/commitlint/ include:
# local: /templates/Semantic-release.yaml
# IMPORTANT NOTE
# ==============
#
# We can't merge rules with `!reference` until we switch to Gitlab >= 14.3
# https://gitlab.com/gitlab-org/gitlab/-/issues/322992
# Use a `.rules-map` as a workaround
#
semantic-release:
extends: .semantic-release:stable
.on-stable-with-semantic-release-config:
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
exists:
- release.config.js
- .releaserc
- .releaserc.yaml
- .releaserc.yml
- .releaserc.json
- .releaserc.js
when: on_success
.on-testing-with-semantic-release-config:
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
exists:
- release.config.js
- .releaserc
- .releaserc.yaml
- .releaserc.yml
- .releaserc.json
- .releaserc.js
when: on_success
.on-dev-with-semantic-release-config: semantic-release: {extends: '.semantic-release:stable'}
rules:
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
exists:
- release.config.js
- .releaserc
- .releaserc.yaml
- .releaserc.yml
- .releaserc.json
- .releaserc.js
when: on_success
.semantic-release:stable: deprecation-semantic-release:
stage: release # Execute at the same time
extends: .on-stable-with-semantic-release-config extends: semantic-release
image: "$SEMANTIC_RELEASE_IMAGE" # The failure must be a warning
variables: allow_failure: true
SEMANTIC_RELEASE_IMAGE: 'hub.eole.education/eole/semantic-release-gitlab:latest'
script: 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'
... ...
...@@ -70,6 +70,14 @@ variables: ...@@ -70,6 +70,14 @@ variables:
- !reference [.rules-map, not-on-semantic-release-commit] - !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branch] - !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 # Select the developpment branch
.on-dev: .on-dev:
rules: rules:
......
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.semantic-release:stable`: create a stable release
#
# - `.semantic-release:testing`: create a prerelease on
# `$TESTING_BRANCH`, requires corresponding configuration in
# `semantic-release` configuration file
#
# - `.semantic-release:dev`: create a prerelease on `$DEV_BRANCH`
# requires corresponding configuration in `semantic-release`
# configuration file
#
---
#
# .semantic-release:stable
# ========================
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: main
# file: /templates/Semantic-release.yaml
#
# new-release:
# extends: .semantic-release:stable
#
# 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`
#
# - the `.on-stable` rules templates or it must be overriden by the
# extending job to feet your need
#
# - an access token named `GITLAB_TOKEN` with
# - `api`
# - `read_repository`
# - `write_repository`
#
# - The variable `$STABLE_BRANCH` defined
#
# OPTIONAL VARIABLES
# ==================
#
# - `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
# Use a `.rules-map` as a workaround
#
.semantic-release:stable:
stage: release
extends: .on-stable
image: "$SEMANTIC_RELEASE_IMAGE"
variables:
SEMANTIC_RELEASE_IMAGE: 'hub.eole.education/eole/semantic-release-gitlab:latest'
script:
- 'semantic-release'
#
# .semantic-release:testing
# =========================
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: main
# file: /templates/Semantic-release.yaml
#
# testing-prerelease:
# extends: .semantic-release:testing
#
# 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`
#
# - the `.on-testing` rules templates or it must be overriden by the
# extending job to feet your need
#
# - an access token named `GITLAB_TOKEN` with
# - `api`
# - `read_repository`
# - `write_repository`
#
# - The variable `$TESTING_BRANCH` defined
#
# OPTIONAL VARIABLES
# ==================
#
# - `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
# Use a `.rules-map` as a workaround
#
.semantic-release:testing:
extends:
- .semantic-release:stable
- .on-testing
#
# .semantic-release:dev
# =====================
#
# USAGE
# =====
#
# include:
# - project: EOLE/Infra/ci-tools
# ref: main
# file: /templates/Semantic-release.yaml
#
# dev-prerelease:
# extends: .semantic-release:dev
#
# 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`
#
# - the `.on-dev` rules templates or it must be overriden by the
# extending job to feet your need
#
# - an access token named `GITLAB_TOKEN` with
# - `api`
# - `read_repository`
# - `write_repository`
#
# - The variable `$DEV_BRANCH` defined
#
# OPTIONAL VARIABLES
# ==================
#
# - `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
# Use a `.rules-map` as a workaround
#
.semantic-release:dev:
extends:
- .semantic-release:stable
- .on-dev
...