Skip to content

Commit 7d59cce

Browse files
authored
ci: integrate semantic release in GitLab CI/CD (#553)
1 parent 01a96e7 commit 7d59cce

File tree

5 files changed

+49
-54
lines changed

5 files changed

+49
-54
lines changed

.gitlab/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,17 @@ consistency:
4343
- git status --porcelain
4444
- test -z "$(git status --porcelain)"
4545
stage: ci
46+
semantic-release:
47+
image:
48+
name: node:20.13.1
49+
interruptible: true
50+
rules:
51+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "serious-scaffold" && $CI_PROJECT_NAME == "ss-python"
52+
script:
53+
- >
54+
npx
55+
-p @semantic-release/gitlab@13
56+
-p conventional-changelog-conventionalcommits@7
57+
-p semantic-release@23
58+
semantic-release
59+
stage: release

.gitlab/workflows/release.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ pages-build:
22
artifacts:
33
paths:
44
- public
5-
- docs/changelog.md
6-
- release-notes.md
75
cache:
86
paths:
97
- .venv
@@ -17,26 +15,22 @@ pages-build:
1715
script:
1816
- make dev-doc
1917
- make doc
20-
- make release-notes > release-notes.md
2118
stage: release
22-
release-publish:
23-
image: registry.gitlab.com/gitlab-org/release-cli:v0.18.0@sha256:696013aea0f2a20482800ce3a77341f840d7c7ec17bd78bd555e0bd6c00e4f11
19+
pages:
20+
artifacts:
21+
paths:
22+
- public
2423
needs:
2524
- pages-build
26-
release:
27-
description: release-notes.md
28-
tag_name: $CI_COMMIT_TAG
2925
rules:
3026
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
3127
script:
32-
- echo "Running the release job."
28+
- echo "Running the pages job."
3329
stage: release
3430
variables:
3531
GIT_STRATEGY: none
3632
container-publish:
3733
image: docker:26.1.2@sha256:c890c327e515cdccd14e593fb5450e4375e791ab0520795948134cb87b45aaa7
38-
needs:
39-
- release-publish
4034
parallel:
4135
matrix:
4236
- PYTHON_VERSION:
@@ -82,24 +76,8 @@ container-publish:
8276
PYTHON_VERSION: ${PYTHON_VERSION}
8377
SOURCE_DATE_EPOCH: 0
8478
package-publish:
85-
needs:
86-
- release-publish
8779
rules:
8880
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
8981
script:
9082
- make publish
9183
stage: release
92-
pages:
93-
artifacts:
94-
paths:
95-
- public
96-
needs:
97-
- pages-build
98-
- release-publish
99-
rules:
100-
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
101-
script:
102-
- echo "Running the pages job."
103-
stage: release
104-
variables:
105-
GIT_STRATEGY: none

template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,17 @@ consistency:
5656
- test -z "$(git status --porcelain)"
5757
stage: ci
5858
[%- endif %]
59+
semantic-release:
60+
image:
61+
name: node:20.13.1
62+
interruptible: true
63+
rules:
64+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "{{ repo_namespace }}" && $CI_PROJECT_NAME == "{{ repo_name }}"
65+
script:
66+
- >
67+
npx
68+
-p @semantic-release/gitlab@13
69+
-p conventional-changelog-conventionalcommits@7
70+
-p semantic-release@23
71+
semantic-release
72+
stage: release

template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ pages-build:
33
artifacts:
44
paths:
55
- public
6-
- docs/changelog.md
7-
- release-notes.md
86
cache:
97
paths:
108
- .venv
@@ -18,26 +16,22 @@ pages-build:
1816
script:
1917
- make dev-doc
2018
- make doc
21-
- make release-notes > release-notes.md
2219
stage: release
23-
release-publish:
24-
image: registry.gitlab.com/gitlab-org/release-cli:v0.18.0@sha256:696013aea0f2a20482800ce3a77341f840d7c7ec17bd78bd555e0bd6c00e4f11
20+
pages:
21+
artifacts:
22+
paths:
23+
- public
2524
needs:
2625
- pages-build
27-
release:
28-
description: release-notes.md
29-
tag_name: $CI_COMMIT_TAG
3026
rules:
3127
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
3228
script:
33-
- echo "Running the release job."
29+
- echo "Running the pages job."
3430
stage: release
3531
variables:
3632
GIT_STRATEGY: none
3733
container-publish:
3834
image: docker:26.1.2@sha256:c890c327e515cdccd14e593fb5450e4375e791ab0520795948134cb87b45aaa7
39-
needs:
40-
- release-publish
4135
parallel:
4236
matrix:
4337
- PYTHON_VERSION:
@@ -93,24 +87,8 @@ container-publish:
9387
PYTHON_VERSION: ${PYTHON_VERSION}
9488
SOURCE_DATE_EPOCH: 0
9589
package-publish:
96-
needs:
97-
- release-publish
9890
rules:
9991
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
10092
script:
10193
- make publish
10294
stage: release
103-
pages:
104-
artifacts:
105-
paths:
106-
- public
107-
needs:
108-
- pages-build
109-
- release-publish
110-
rules:
111-
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
112-
script:
113-
- echo "Running the pages job."
114-
stage: release
115-
variables:
116-
GIT_STRATEGY: none

template/package.json renamed to template/package.json.jinja

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@
118118
}
119119
}
120120
],
121+
[%- if repo_platform == 'github' %]
121122
"@semantic-release/github"
123+
[%- elif repo_platform == 'gitlab' %]
124+
"@semantic-release/gitlab"
125+
[%- elif repo_platform == 'gitlab-self-managed' %]
126+
[
127+
"@semantic-release/gitlab",
128+
{
129+
"gitlabUrl": "https://{{ repo_host }}"
130+
}
131+
]
132+
[%- endif %]
122133
],
123134
"preset": "conventionalcommits"
124135
}

0 commit comments

Comments
 (0)