-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
100 lines (93 loc) · 4.05 KB
/
.gitlab-ci.yml
File metadata and controls
100 lines (93 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Include Rust-specific CI configuration
include:
- local: '.gitlab/ci/rust.gitlab-ci.yml'
- local: '.gitlab/ci/devcontainer.gitlab-ci.yml'
# Global variables for package versions
variables:
COMMITLINT_CLI_VERSION: "17.6.1"
COMMITLINT_CONFIG_VERSION: "17.6.1"
SEMANTIC_RELEASE_VERSION: "21.0.7"
SEMANTIC_RELEASE_CHANGELOG_VERSION: "6.0.3"
SEMANTIC_RELEASE_GIT_VERSION: "10.0.1"
SEMANTIC_RELEASE_GITLAB_VERSION: "12.1.1"
SEMANTIC_RELEASE_EXEC_VERSION: "6.0.3"
SEMANTIC_RELEASE_CARGO_VERSION: "2.4.44"
CONVENTIONAL_CHANGELOG_CONVENTIONALCOMMITS_VERSION: "7.0.2"
# Workflow rules for automatic pipeline cancellation
workflow:
auto_cancel:
on_new_commit: interruptible
on_job_failure: none
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
# Skip branch pipeline for release commits (tag pipeline will run instead)
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE =~ /^chore\(release\):/
when: never
# Disable auto-cancel for release pipelines
- if: '$RELEASE_ENABLED == "true"'
auto_cancel:
on_new_commit: none
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
# Semantic release job template - common setup for semantic-release jobs
.semantic-release-template: &semantic-release-template
image: rust:1.94.0@sha256:72724f1a416c449b405a2b7ed6bac56058163e6dfb1b5ccb40839882141dd237
before_script:
# Install Node.js in Rust image
- apt-get update -qq && apt-get install -y -qq curl
- curl -fsSL https://nodejs.org/dist/v20.11.1/node-v20.11.1-linux-x64.tar.xz | tar -xJ -C /usr/local --strip-components=1
- node --version
- npm --version
# Install semantic-release and plugins
- npm install -g semantic-release@${SEMANTIC_RELEASE_VERSION} @semantic-release/changelog@${SEMANTIC_RELEASE_CHANGELOG_VERSION} @semantic-release/git@${SEMANTIC_RELEASE_GIT_VERSION} @semantic-release/gitlab@${SEMANTIC_RELEASE_GITLAB_VERSION} @semantic-release/exec@${SEMANTIC_RELEASE_EXEC_VERSION} conventional-changelog-conventionalcommits@${CONVENTIONAL_CHANGELOG_CONVENTIONALCOMMITS_VERSION}
# Install semantic-release-cargo static binary
- curl -L https://github.com/semantic-release-cargo/semantic-release-cargo/releases/download/v${SEMANTIC_RELEASE_CARGO_VERSION}/semantic-release-cargo-x86_64-unknown-linux-musl -o /usr/local/bin/semantic-release-cargo
- chmod +x /usr/local/bin/semantic-release-cargo
- semantic-release-cargo --version
interruptible: true
# Pipeline stages
stages:
- build
- test
- lint
- docs
- release
# Commit lint job - check commit message format
commitlint:
image: node:24.14.0@sha256:5a593d74b632d1c6f816457477b6819760e13624455d587eef0fa418c8d0777b
stage: lint
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: "$CI_COMMIT_TAG"
when: never
variables:
GIT_FETCH_EXTRA_FLAGS: "+refs/heads/main:refs/remotes/origin/main"
before_script:
- npm install -g @commitlint/cli@${COMMITLINT_CLI_VERSION} @commitlint/config-conventional@${COMMITLINT_CONFIG_VERSION}
script:
- commitlint --from=$(git merge-base origin/main HEAD) --to=$CI_COMMIT_SHA
interruptible: true
# Semantic release config lint job - validate semantic-release configuration
semantic-release-lint:
<<: *semantic-release-template
stage: lint
script:
- semantic-release --dry-run --no-ci
# Semantic release job - automated versioning and releases
semantic-release:
<<: *semantic-release-template
stage: release
interruptible: false
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $RELEASE_ENABLED == "true"'
- if: '$CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $RELEASE_ENABLED == "true"'
variables:
GIT_FETCH_EXTRA_FLAGS: "+refs/heads/main:refs/remotes/origin/main"
before_script:
- !reference [.semantic-release-template, before_script]
# Configure git
- git config user.name "${GITLAB_USER_NAME}"
- git config user.email "${GITLAB_USER_EMAIL}"
script:
- semantic-release