Skip to content

Commit f1e282e

Browse files
committed
Add gitlab workflow
1 parent d2dab0a commit f1e282e

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

‎.gitlab-ci.yml‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
stages:
2+
- build
3+
- release
4+
5+
build:
6+
stage: build
7+
image: node:22
8+
rules:
9+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/'
10+
script:
11+
# Install dependencies from GitHub Packages
12+
- npm ci
13+
14+
# lint, test
15+
- npm run lint
16+
- npm test
17+
18+
# Check changelog entry exists for this version
19+
- |
20+
VERSION="${CI_COMMIT_TAG#v}"
21+
if ! grep -q "## \[${VERSION}\]" CHANGELOG.md; then
22+
echo "Error: No changelog entry found for version ${VERSION} in CHANGELOG.md"
23+
exit 1
24+
fi
25+
26+
# Check no pre-release changelog entries exist for a stable release
27+
- |
28+
VERSION="${CI_COMMIT_TAG#v}"
29+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
30+
if grep -qP "^## \[$VERSION-" CHANGELOG.md; then
31+
echo "Error: CHANGELOG.md contains pre-release entries for $VERSION:"
32+
grep -P "^## \[$VERSION-" CHANGELOG.md
33+
echo ""
34+
echo "A stable release changelog entry must not list pre-release variants of the same version."
35+
echo "Remove or consolidate the pre-release entries before releasing."
36+
exit 1
37+
fi
38+
fi
39+
40+
# Extract release notes for this version
41+
- |
42+
VERSION="${CI_COMMIT_TAG#v}"
43+
awk "/^## \[${VERSION}\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md > release-notes.md
44+
echo "Release notes:"
45+
cat release-notes.md
46+
47+
# Publish to GitHub Packages
48+
- echo "@galactic-wolf:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
49+
- echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
50+
- npm publish
51+
52+
artifacts:
53+
paths:
54+
- release-notes.md
55+
expire_in: 1 hour
56+
57+
release:
58+
stage: release
59+
image: registry.gitlab.com/gitlab-org/release-cli:latest
60+
needs:
61+
- job: build
62+
artifacts: true
63+
rules:
64+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/'
65+
script:
66+
- echo "Creating GitLab release for ${CI_COMMIT_TAG}"
67+
release:
68+
tag_name: $CI_COMMIT_TAG
69+
name: $CI_COMMIT_TAG
70+
description: "./release-notes.md"
71+

0 commit comments

Comments
 (0)