feat: documentation

Co-authored-by: Richard Attermeyer <richard.attermeyer@opitz-consulting.com>
Reviewed-on: https://git.192.168.1.151.nip.io:8543/fjadmin/ci-demo-2/pulls/4
pull/1/head
fjadmin 2023-11-08 11:10:02 +00:00 committed by Richard Attermeyer
parent 22a3f74737
commit 9d7827eab9
10 changed files with 108 additions and 2 deletions

View File

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="19" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="temurin-17 (4)" project-jdk-type="JavaSDK" />
<component name="ProjectType">
<option name="id" value="jpab" />
</component>

View File

@ -14,7 +14,7 @@ steps:
image: *java_image
commands:
- gradle spotlessCheck --no-daemon
"lint:hadolint":
"lint:dockerfile":
group: lint
image: ghcr.io/hadolint/hadolint:latest-debian
commands:
@ -28,5 +28,16 @@ steps:
image: *java_image
commands:
- ./gradlew cyclonedxBom
"deploy:backend":
image: alpine:latest
commands:
- echo "deploy frontend"
- env
directory: frontend
when:
- event: [deployment]
depends_on:
- "lint_general"

View File

@ -48,5 +48,14 @@ steps:
- npx @cyclonedx/cyclonedx-npm --output-file bom.json
directory: frontend
"deploy:frontend":
image: alpine:latest
commands:
- echo "deploy frontend"
- env
directory: frontend
when:
- event: [manual]
depends_on:
- "lint_general"

View File

@ -0,0 +1,24 @@
---
when:
branch: dev
clone:
git:
image: woodpeckerci/plugin-git
settings:
skip_verify: true
partial: true
steps:
"version:update":
image: bitnami/git:2.42.1
commands:
- echo "$CI_COMMIT_MESSAGE" | ./version-auto-update.sh
- git config --global http.sslVerify false
- git remote set-url origin "https://$CI_COMMIT_AUTHOR:$GIT_PAT@$(echo $CI_REPO_CLONE_URL | cut -b9-)"
- "git config --global user.name $CI_COMMIT_AUTHOR"
- "git config --global user.email $CI_COMMIT_AUTHOR_EMAIL"
- "git commit -am \"chore: auto update version [skip ci]\""
- "git push origin HEAD:dev"
secrets: [git_pat]
depends_on:
- "lint_general"

1
README.md Normal file
View File

@ -0,0 +1 @@
# Demo CI

0
app/README.md Normal file
View File

20
version-auto-update.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
read -r msg
if [[ $msg = *"BREAKING CHANGE:"* ]]; then
./update-version.sh MAJOR
fi
summary=$(echo "$msg" | head -1)
type=$(cut -d':' -f1 <<< "$summary")
if [[ $type = *"!"* ]]; then
./version-update.sh MAJOR
fi
if [[ $type = "feat" ]]; then
./version-update.sh MINOR
else
echo "last commit message does not indicate a base version update, skipping"
fi

11
version-update.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
source version.sh
if [ "MINOR" == "$1" ] ; then
NEW_VERSION=$(awk -F. '{printf("%s.%s", $1, int($2+1))}' version.txt)
elif [ "MAJOR" == "$1" ] ; then
NEW_VERSION=$(awk -F. '{printf("%s.0", int($1+1))}' version.txt)
fi
echo "${NEW_VERSION}"
echo "${NEW_VERSION}" > version.txt

29
version.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# We only want to tag in git when the version changes
# Next version is based on versioned version.txt
# using git describe requires a tag at the begging of development, not at the end
TRUNK_BRANCH="dev"
CD_BASE_VERSION=$(cat version.txt)
CD_PATCH=$(git rev-list --count HEAD ^"${TRUNK_BRANCH}")
CD_QUALIFIER=$(git rev-parse --short HEAD)
CD_CURRENT_RELEASE_TAG=$(git tag -l --contains HEAD)
CD_NEXT_VERSION="${CD_BASE_VERSION}.${CD_PATCH}"
CD_NEXT_QUALIFIED_VERSION="${CD_BASE_VERSION}.${CD_PATCH}-${CD_QUALIFIER}"
CD_NEXT_MAJOR_TAG=$(cut -d'.' -f1 <<< "${CD_BASE_VERSION}")
export CD_BASE_VERSION
export CD_PATCH
export CD_QUALIFIER
export CD_RELEASE_TAG
export CD_NEXT_QUALIFIED_VERSION
export CD_NEXT_MAJOR_TAG
echo "Example versioning"
echo "Trunk Branch: ${TRUNK_BRANCH}"
echo "Java Development Version: ${CD_BASE_VERSION}.0-SNAPSHOT"
echo "NPM Development Version: ${CD_BASE_VERSION}.alpha.0"
echo "Next Release Version: ${CD_NEXT_VERSION}"
echo "Next qualified Release Version: ${CD_NEXT_QUALIFIED_VERSION}"
echo "BASE TAG: ${CD_BASE_VERSION}"
echo "Next Major Release Tag: ${CD_NEXT_MAJOR_TAG}"
echo "Current Release Tag (normally get from pipeline CI_COMMIT_TAG): ${CD_RELEASE_TAG}"

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.6