Skip to content

Commit 1f2a6fb

Browse files
committed
feat: ci
1 parent cc84940 commit 1f2a6fb

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.gitlab-ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
stages:
2+
- build_and_deploy
3+
4+
build_and_deploy:
5+
stage: build_and_deploy
6+
when: manual
7+
rules:
8+
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
9+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
10+
image:
11+
name: gitlab.codingame.com:5050/codingame/tools/build-release:master
12+
entrypoint: [""]
13+
variables:
14+
- VERSION
15+
- AUTO_RELEASE_NOTES
16+
- MAVEN_OPTS: "-Xms4096M -Xmx4096M -XX:MaxMetaspaceSize=1024M"
17+
script: |
18+
set -e # fail on 1st error
19+
20+
rm -rf docs
21+
find . -type f -name pom.xml | xargs sed -i "s/master\\-SNAPSHOT/$VERSION/g"
22+
mvn -amd -B -U clean deploy
23+
mvn javadoc:aggregate
24+
rm -rf docs
25+
mkdir docs
26+
cp -R target/site/apidocs/* docs/
27+
git add docs
28+
if [ -z $(git tag -l $VERSION) ]
29+
then
30+
git commit -m "javadoc v$VERSION"
31+
git tag "v$VERSION" -m ""
32+
git push origin "v$VERSION"
33+
git push origin master
34+
fi
35+
36+
if $AUTO_RELEASE_NOTES ; then
37+
RELEASE_NOTES=$(.gitlab/extract_release_notes.js playground/misc/misc-3-release-notes.md $VERSION)
38+
DATA=$(jq -n --arg body "$RELEASE_NOTES" --arg version "v$VERSION" '{body:$body, tag_name:$version, name:$version, draft:true}')
39+
curl -i -H "Authorization: token $GITHUB_TOKEN" \
40+
-d "$DATA" https://api.github.com/repos/CodinGame/codingame-game-engine/releases
41+
fi

.gitlab/extract_release_notes.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const filename = process.argv[2]
5+
const version = process.argv[3]
6+
const file = fs.readFileSync(filename, "utf8");
7+
const escaped = version.replace(/\./g, '\\.')
8+
const regexp = new RegExp(`## ${escaped}\\n*(?<notes>(?:.|\\n)*?)## \\d+\\.\\d+\\.\\d+`, 'gm')
9+
const match = regexp.exec(file)
10+
11+
if (match) {
12+
console.log(match[1])
13+
} else {
14+
throw new Error(`Couldn't find version ${version} in release notes. Don't forget to update '## Next release' in misc-3-release-notes.md`)
15+
}

0 commit comments

Comments
 (0)