Skip to content

Commit

Permalink
ci: integrate semantic release in GitLab CI/CD (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored May 18, 2024
1 parent 01a96e7 commit 7d59cce
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 54 deletions.
14 changes: 14 additions & 0 deletions .gitlab/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ consistency:
- git status --porcelain
- test -z "$(git status --porcelain)"
stage: ci
semantic-release:
image:
name: node:20.13.1
interruptible: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "serious-scaffold" && $CI_PROJECT_NAME == "ss-python"
script:
- >
npx
-p @semantic-release/gitlab@13
-p conventional-changelog-conventionalcommits@7
-p semantic-release@23
semantic-release
stage: release
32 changes: 5 additions & 27 deletions .gitlab/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ pages-build:
artifacts:
paths:
- public
- docs/changelog.md
- release-notes.md
cache:
paths:
- .venv
Expand All @@ -17,26 +15,22 @@ pages-build:
script:
- make dev-doc
- make doc
- make release-notes > release-notes.md
stage: release
release-publish:
image: registry.gitlab.com/gitlab-org/release-cli:v0.18.0@sha256:696013aea0f2a20482800ce3a77341f840d7c7ec17bd78bd555e0bd6c00e4f11
pages:
artifacts:
paths:
- public
needs:
- pages-build
release:
description: release-notes.md
tag_name: $CI_COMMIT_TAG
rules:
- 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]*)?)?$/
script:
- echo "Running the release job."
- echo "Running the pages job."
stage: release
variables:
GIT_STRATEGY: none
container-publish:
image: docker:26.1.2@sha256:c890c327e515cdccd14e593fb5450e4375e791ab0520795948134cb87b45aaa7
needs:
- release-publish
parallel:
matrix:
- PYTHON_VERSION:
Expand Down Expand Up @@ -82,24 +76,8 @@ container-publish:
PYTHON_VERSION: ${PYTHON_VERSION}
SOURCE_DATE_EPOCH: 0
package-publish:
needs:
- release-publish
rules:
- 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]*)?)?$/
script:
- make publish
stage: release
pages:
artifacts:
paths:
- public
needs:
- pages-build
- release-publish
rules:
- 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]*)?)?$/
script:
- echo "Running the pages job."
stage: release
variables:
GIT_STRATEGY: none
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ consistency:
- test -z "$(git status --porcelain)"
stage: ci
[%- endif %]
semantic-release:
image:
name: node:20.13.1
interruptible: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "{{ repo_namespace }}" && $CI_PROJECT_NAME == "{{ repo_name }}"
script:
- >
npx
-p @semantic-release/gitlab@13
-p conventional-changelog-conventionalcommits@7
-p semantic-release@23
semantic-release
stage: release
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pages-build:
artifacts:
paths:
- public
- docs/changelog.md
- release-notes.md
cache:
paths:
- .venv
Expand All @@ -18,26 +16,22 @@ pages-build:
script:
- make dev-doc
- make doc
- make release-notes > release-notes.md
stage: release
release-publish:
image: registry.gitlab.com/gitlab-org/release-cli:v0.18.0@sha256:696013aea0f2a20482800ce3a77341f840d7c7ec17bd78bd555e0bd6c00e4f11
pages:
artifacts:
paths:
- public
needs:
- pages-build
release:
description: release-notes.md
tag_name: $CI_COMMIT_TAG
rules:
- 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]*)?)?$/
script:
- echo "Running the release job."
- echo "Running the pages job."
stage: release
variables:
GIT_STRATEGY: none
container-publish:
image: docker:26.1.2@sha256:c890c327e515cdccd14e593fb5450e4375e791ab0520795948134cb87b45aaa7
needs:
- release-publish
parallel:
matrix:
- PYTHON_VERSION:
Expand Down Expand Up @@ -93,24 +87,8 @@ container-publish:
PYTHON_VERSION: ${PYTHON_VERSION}
SOURCE_DATE_EPOCH: 0
package-publish:
needs:
- release-publish
rules:
- 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]*)?)?$/
script:
- make publish
stage: release
pages:
artifacts:
paths:
- public
needs:
- pages-build
- release-publish
rules:
- 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]*)?)?$/
script:
- echo "Running the pages job."
stage: release
variables:
GIT_STRATEGY: none
11 changes: 11 additions & 0 deletions template/package.json → template/package.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,18 @@
}
}
],
[%- if repo_platform == 'github' %]
"@semantic-release/github"
[%- elif repo_platform == 'gitlab' %]
"@semantic-release/gitlab"
[%- elif repo_platform == 'gitlab-self-managed' %]
[
"@semantic-release/gitlab",
{
"gitlabUrl": "https://{{ repo_host }}"
}
]
[%- endif %]
],
"preset": "conventionalcommits"
}
Expand Down

0 comments on commit 7d59cce

Please sign in to comment.