From 62f6bd439e72e7cae1b80e76cad4d43e17639f95 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Apr 2026 02:23:21 -0500 Subject: [PATCH] Add release job to GitLab CI Triggered by version tags (vX.Y.Z), extracts the changelog section for the tagged version and creates a GitLab release with it. --- .gitlab-ci.yml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc2a8355..ca1a990d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,9 +7,14 @@ default: stages: - test - deploy + - release test: stage: test + rules: + - if: $CI_COMMIT_TAG + when: never + - when: always script: - npm run typecheck - npm run build @@ -17,6 +22,10 @@ test: pages: stage: deploy + rules: + - if: $CI_COMMIT_TAG + when: never + - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH script: - npm run build - rm -rf public @@ -24,6 +33,24 @@ pages: artifacts: paths: - public - only: - variables: - - $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME + +release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + script: + - echo "Creating release for $CI_COMMIT_TAG" + # Extract the latest changelog section for the release description. + # Reads from "## [version]" to the next "## [" or end of file. + - | + VERSION="${CI_COMMIT_TAG#v}" + RELEASE_NOTES=$(awk "/^## \\[${VERSION}\\]/{found=1; next} /^## \\[/{if(found) exit} found{print}" CHANGELOG.md) + if [ -z "$RELEASE_NOTES" ]; then + RELEASE_NOTES="Shakespeare ${CI_COMMIT_TAG}" + fi + - echo "$RELEASE_NOTES" > release-notes.md + release: + tag_name: $CI_COMMIT_TAG + name: $CI_COMMIT_TAG + description: './release-notes.md'