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 (13)
extends:
- '@commitlint/config-conventional'
rules:
body-max-line-length: [2, 'always', 120]
footer-max-line-length: [2, 'always', 120]
header-max-length: [2, 'always', 72]
......@@ -4,9 +4,9 @@
include:
- local: templates/Rules.yaml
- local: templates/Runners/eole-docker.yaml
- local: templates/Lint/Commitlint.yaml
- local: templates/Git.yaml
- local: templates/Docker.yaml
- local: templates/Release/Semantic-release.yaml
- local: templates/Semantic-release.yaml
stages:
- lint
......@@ -18,6 +18,11 @@ stages:
matrix:
- IMAGE_NAME: [commitlint, semantic-release-gitlab]
###############################################################################
# `lint` stage: `commitlint`
###############################################################################
commitlint: {extends: '.git:commitlint'}
###############################################################################
# `build` stage: `*-docker-build`
###############################################################################
......@@ -25,16 +30,19 @@ stages:
build-docker:
extends:
- .docker-matrix
- .build-docker-image
- .docker:image:build
###############################################################################
# `release` stage: `semantic-release`, `*-docker-tag`
# `release` stage: `new-release`, `tag *`
###############################################################################
# Create the release versions on `$STABLE_BRANCH`
new release: {extends: '.semantic-release:stable'}
# Suffix all jobs to avoid conflict with other jobs names
.tag-docker:
extends:
- .docker-matrix
- .tag-docker-image
- .docker:image:tag
## tag contribution branches with a more stable name than `git-${CI_COMMIT_SHORT_SHA}`
tag contrib branch:
......
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [2, 'always', 120],
'footer-max-line-length': [2, 'always', 120],
'header-max-length': [2, 'always', 72],
},
};
# Changelog
# [1.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)
......
This diff is collapsed.
......@@ -9,16 +9,31 @@ const gitAssets = [];
// Configure your branches names
const stableBranch = 'stable';
// Assign a branch name to produce a `testing` prerelease tag
const testingBranch = undefined;
// Assign a branch name to produce a `beta` prerelease tag
const betaBranch = undefined;
// Assign a branch name to produce a `alpha` prerelease tag
const alphaBranch = undefined;
// Assign a branch name to produce a `dev` prerelease tag
const devBranch = undefined;
// Configure semantic-release plugins
const breakingKeywords = ["BREAKING CHANGE", "BREAKING-CHANGE", "BREAKING CHANGES", "BREAKING-CHANGES"];
const changelogFile = 'docs/CHANGELOG.md';
const semanticBranches = [stableBranch];
if (testingBranch) {
if (betaBranch) {
semanticBranches.push({
name: betaBranch,
prerelease: true
});
}
if (alphaBranch) {
semanticBranches.push({
name: testingBranch,
name: alphaBranch,
prerelease: true
});
}
......@@ -39,10 +54,23 @@ const config = {
'@semantic-release/commit-analyzer',
{
preset: 'angular',
parserOpts:
{
noteKeywords: breakingKeywords,
},
releaseRules: './release-rules.js',
},
],
'@semantic-release/release-notes-generator',
[
'@semantic-release/release-notes-generator',
{
preset: 'angular',
parserOpts:
{
noteKeywords: breakingKeywords,
},
},
],
],
};
......@@ -54,11 +82,11 @@ if (
config.plugins.push([
'@semantic-release/changelog',
{
changelogFile: 'docs/CHANGELOG.md',
changelogFile: changelogFile,
changelogTitle: '# Changelog',
},
]);
gitAssets.push('docs/CHANGELOG.md');
gitAssets.push(changelogFile);
}
// // We need to update package*.json
......@@ -99,89 +127,4 @@ config.plugins.push(
'@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;
# -*- mode: yaml; coding: utf-8 -*-
# vim: ft=yaml
#
# Define `.build-docker-image` template used by `*-docker-build` jobs
# It build the container image and push it to `${CI_REGISTRY}`
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.docker:image:build`: build a docker image with `kaniko:executor`
#
# - `.docker:image:tag`: tag docker image with `crane`
#
---
#
# .docker:image:build
# ===================
#
# Build the container image `${IMAGE_NAME}:${IMAGE_TAG}` and push it to `${CI_REGISTRY}`
#
# USAGE
# =====
#
# foo-docker-build:
# extends: .build-docker-image
# extends: .docker:image:build
# variables:
# DOCKERFILE: Some-specific.Dockerfile
# IMAGE_TAG: $CI_COMMIT_REF_SLUG
......@@ -16,92 +26,142 @@
# REQUIREMENTS
# ============
#
# - A `build` stage must be present in your pipeline or it must be
# - a `build` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
# - The `.not-on-stable` rules template
#
# - the `.not-on-stable` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `IMAGE_NAME`: defaults to `${CI_JOB_NAME}` with any suffix `-docker-build*` removed
# - `IMAGE_NAME`: name of the docker image to build, defaults to
# `${CI_JOB_NAME}` with any suffix `-docker-build*` removed
#
# - `IMAGE_TAG`: tag of the docker image, defaults to
# `git-${CI_COMMIT_SHORT_SHA}`
#
# - `DOCKERFILE`: defaults, in order
# - to value set by the user
# - to `Dockerfile.${IMAGE_NAME}` if the file exists
# - to `Dockerfile` if the file exists
# - `IMAGE_TAG`: defaults to `git-${CI_COMMIT_SHORT_SHA}`
# - `KANIKO_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
# =================
#
# - `CI_REGISTRY`
#
# - `CI_REGISTRY_USER`
#
# - `CI_REGISTRY_PASSWORD`
#
# - `CI_REGISTRY_IMAGE`
#
.build-docker-image:
.docker:image:build:
stage: build
extends: .not-on-stable
image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug
name: "${KANIKO_IMAGE}"
entrypoint: [""]
variables:
KANIKO_IMAGE: gcr.io/kaniko-project/executor:v1.7.0-debug
KANIKO_ARGS: ''
script:
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-build-config[collapsed=true]\r\e[0KPrepare environment to build docker image"
- export IMAGE_NAME=${IMAGE_NAME:-${CI_JOB_NAME%-docker-build*}}
- test -f Dockerfile.${IMAGE_NAME} && export DOCKERFILE=${DOCKERFILE:-Dockerfile.${IMAGE_NAME}} || true
- test -f Dockerfile && export DOCKERFILE=${DOCKERFILE:-Dockerfile} || true
- export IMAGE_TAG=${IMAGE_TAG:-git-${CI_COMMIT_SHORT_SHA}}
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-build-config\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-build-kaniko\r\e[0KBuild docker image '${IMAGE_NAME}:${IMAGE_TAG}' using Dockerfile '${DOCKERFILE}' and push to '${CI_REGISTRY_IMAGE}'"
- /kaniko/executor ${KANIKO_ARGS} --context ${CI_PROJECT_DIR} --dockerfile $CI_PROJECT_DIR/${DOCKERFILE} --destination ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-build-kaniko\r\e[0K"
.build-docker-image:
extends: .docker:image:build
before_script:
- 'echo "DEPRECATION WARNING: use .docker:image:build instead"'
# Define `.tag-docker-image` template used by `*-docker-tag` jobs
# It tag the `${IMAGE_NAME}:${SOURCE_TAG}` with the tag `${IMAGE_TAG}`
#
# .docker:image:tag
# =================
#
# Tag the `${IMAGE_NAME}:${SOURCE_TAG}` with the new tag `${IMAGE_TAG}`
#
# USAGE
# =====
#
# foo-docker-tag-devel:
# extends: .tag-docker-image
# extends: .docker:image:tag
# variables:
# IMAGE_TAG: 'devel'
#
# REQUIREMENTS
# ============
#
# - A `release` stage must be present in your pipeline or it must be
# - a `release` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need.
# - The `.not-on-stable` rules template
#
# - the `.on-release-tag` rules templates
#
# OPTIONAL VARIABLES
# ==================
#
# - `IMAGE_NAME`: defaults to `${CI_JOB_NAME}` with any suffix `-docker-tag*` removed
# - `SOURCE_TAG`: source image tag to retag, defaults to `git-${CI_COMMIT_SHORT_SHA}`
# - `IMAGE_TAG`: image tag, defaults to `${CI_COMMIT_TAG}` with prefix `RELEASE_PREFIX` removed
# - `RELEASE_PREFIX`: prefix of the `RELEASE`, defaults to `release/`
# - `IMAGE_NAME`: name of the docker image to tag, defaults to
# `CI_JOB_NAME` with any suffix `-docker-tag*` removed
#
# - `SOURCE_TAG`: source image tag to retag, defaults to
# `git-${CI_COMMIT_SHORT_SHA}`
#
# - `IMAGE_TAG`: image tag, defaults to `${CI_COMMIT_TAG}` with
# prefix `${RELEASE_TAG_PREFIX}` removed
#
# - `RELEASE_TAG_PREFIX`: prefix of the `RELEASE`, defaults to
# `release/`
#
# - `CRANE_IMAGE`: name of the `crane` docker image to use
#
# USED CI VARIABLES
# =================
#
# - `CI_REGISTRY`
#
# - `CI_REGISTRY_USER`
#
# - `CI_REGISTRY_PASSWORD`
#
# - `CI_REGISTRY_IMAGE`
#
.tag-docker-image:
.docker:image:tag:
stage: release
extends: .on-release-tag
image:
name: gcr.io/go-containerregistry/crane:debug
name: "${CRANE_IMAGE}"
entrypoint: [""]
variables:
CRANE_IMAGE: gcr.io/go-containerregistry/crane:debug
GIT_STRATEGY: none
script:
- export IMAGE_NAME=${IMAGE_NAME:-${CI_JOB_NAME%-docker-tag*}}
- export SOURCE_TAG=${SOURCE_TAG:-git-${CI_COMMIT_SHORT_SHA}}
- export RELEASE_PREFIX=${RELEASE_PREFIX:-release/}
- export IMAGE_TAG=${IMAGE_TAG:-${CI_COMMIT_TAG#${RELEASE_PREFIX}}}
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane tag ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${SOURCE_TAG} ${IMAGE_TAG}
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-tag-config[collapsed=true]\r\e[0KPrepare environment to tag docker image"
- export IMAGE_NAME="${IMAGE_NAME:-${CI_JOB_NAME%-docker-tag*}}"
- export SOURCE_TAG="${SOURCE_TAG:-git-${CI_COMMIT_SHORT_SHA}}"
- export RELEASE_TAG_PREFIX="${RELEASE_TAG_PREFIX:-release/}"
- export IMAGE_TAG="${IMAGE_TAG:-${CI_COMMIT_TAG#${RELEASE_TAG_PREFIX}}}"
- crane auth login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-tag-config\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:docker-image-tag-crane\r\e[0KTag docker image '${IMAGE_NAME}:${SOURCE_TAG}' with '${IMAGE_TAG}'"
- crane tag "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${SOURCE_TAG}" "${IMAGE_TAG}"
- echo -e "\e[0Ksection_end:`date +%s`:docker-image-tag-crane\r\e[0K"
.tag-docker-image:
extends: .docker:image:tag
before_script:
- 'echo "DEPRECATION WARNING: use .docker:image:tag instead"'
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Hidden template jobs to be used in `.gitlab-ci.yml`
#
# - `.git:commitlint`: verify formatting of commit messages
#
# - `.git:merge-to`: merge release tags to the `${GIT_MERGE_TARGET}` branch
#
---
#
# .git:commitlint
# ===============
#
# Verify formatting of all commit messages in the range
# `${BASE_BRANCH}..${CI_COMMIT_SHA}`.
#
# USAGE
# =====
#
# include:
# - project: baby-gnu/ci-tools
# ref: main
# file: /templates/Git.yaml
#
# stages:
# - lint
#
# commitlint: {extends: '.git:commitlint'}
#
# REQUIREMENTS
# ============
#
# - a `lint` stage must be present in your pipeline or it must be
# overriden by the extending job to feet your need
#
# - the `.not-on-stable` 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: .not-on-stable
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}'"
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
- 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"
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Verify formatting of all commit messages in the range
# `$BASE_BRANCH..$CI_COMMIT_SHA`.
#
# 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`
# Backward compatible template.
# Use `templates/Git.yaml` instead
#
---
commitlint:
stage: lint
extends: .not-on-stable
image: "$COMMITLINT_IMAGE"
variables:
COMMITLINT_IMAGE: 'hub.eole.education/eole/commitlint:latest'
BASE_BRANCH: "${CI_DEFAULT_BRANCH}"
include:
local: /templates/Git.yaml
commitlint: {extends: '.git:commitlint'}
deprecation-commitlint:
# Execute at the same time
extends: commitlint
# The failure must be a warning
allow_failure: true
script:
- 'git fetch --all'
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base origin/${BASE_BRANCH} HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
- 'echo "DEPRECATION WARNING: replace commitlint by .git:commitlint"'
- 'echo "DEPRECATION WARNING: see /templates/Git.yaml"'
# Be visible in the CI pipeline
- '/bin/false'
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# Produce a new release using semantic versionning scheme when new
# commits arrive on the `$STABLE_BRANCH` branch.
#
# By default, a `semantic-release` job is created for `$STABLE_BRANCH`
# and you can create jobs for `$TESTING_BRANCH` and `$DEV_BRANCH` by
# extending the `.semantic-release:testing` and
# `.semantic-release:dev` template jobs.
#
# USAGE
# =====
#
# include:
# # stable semantic-release job is created by include
# - project: EOLE/infra/ci-tools
# ref: stable
# file: /templates/Release/Semantic-release.yaml
#
# testing-prerelease:
# extends: .semantic-release:testing
#
# 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`
# - 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/
#
# 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
.semantic-release:stable:
stage: release
extends: .on-stable-with-semantic-release-config
image: "$SEMANTIC_RELEASE_IMAGE"
variables:
SEMANTIC_RELEASE_IMAGE: 'hub.eole.education/eole/semantic-release-gitlab:latest'
script:
- 'semantic-release'
.semantic-release:testing:
extends:
- .semantic-release:stable
- .on-testing-with-semantic-release-config
.semantic-release:dev:
extends:
- .semantic-release:stable
- .on-dev-with-semantic-release-config
.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
---
include:
local: /templates/Semantic-release.yaml
.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
semantic-release: {extends: '.semantic-release:stable'}
.on-dev-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 == $DEV_BRANCH
exists:
- release.config.js
- .releaserc
- .releaserc.yaml
- .releaserc.yml
- .releaserc.json
- .releaserc.js
when: on_success
deprecation-semantic-release:
# Execute at the same time
extends: semantic-release
# The failure must be a warning
allow_failure: true
script:
- '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'
...
# -*- 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 `.rules-map` rules templates
#
# - 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-with-semantic-release-config
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 `.rules-map` rules templates
#
# - 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-with-semantic-release-config
#
# .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 `.rules-map` rules templates
#
# - 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-with-semantic-release-config
.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:
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
...