build(version): working on version information (#6)
provide and include better version information in reporting First and foremost, we need to determine the next version id that should be used the artifacts from the current build. 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/6 fix: commitlint (#7) the commit message in the environment variable did not work correctly for multi-line commit messages. 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/7pull/1/head
parent
a1c72d4a08
commit
870eb3598a
|
|
@ -7,30 +7,7 @@ build
|
|||
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
.idea
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
|
|
@ -123,3 +100,8 @@ fabric.properties
|
|||
|
||||
# Node
|
||||
node_modules/
|
||||
|
||||
docker/target/*.jar
|
||||
|
||||
# version-lock as it is only for specific build
|
||||
version-lock.sh
|
||||
|
|
|
|||
|
|
@ -8,7 +8,13 @@ clone:
|
|||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
skip_verify: true
|
||||
partial: false
|
||||
tags: true
|
||||
steps:
|
||||
"prepare:version":
|
||||
image: bitnami/git:2.42.1
|
||||
commands:
|
||||
- . ./version.sh
|
||||
"lint:style":
|
||||
group: lint
|
||||
image: *java_image
|
||||
|
|
@ -23,7 +29,7 @@ steps:
|
|||
group: build
|
||||
image: *java_image
|
||||
commands:
|
||||
- . ./version.sh
|
||||
- . ./version-lock.sh
|
||||
- ./gradlew -Pversion=$CD_CURRENT_VERSION build
|
||||
"analyze:sbom":
|
||||
image: *java_image
|
||||
|
|
|
|||
|
|
@ -9,8 +9,14 @@ clone:
|
|||
settings:
|
||||
skip_verify: true
|
||||
steps:
|
||||
"prepare":
|
||||
"prepare:version":
|
||||
image: bitnami/git:2.42.1
|
||||
group: prepare
|
||||
commands:
|
||||
- . ./version.sh
|
||||
"prepare:frontend":
|
||||
image: *frontend_image
|
||||
group: prepare
|
||||
commands:
|
||||
- pnpm install
|
||||
directory: frontend
|
||||
|
|
|
|||
|
|
@ -5,6 +5,18 @@ clone:
|
|||
settings:
|
||||
skip_verify: true
|
||||
steps:
|
||||
"prepare:commitlint":
|
||||
image: bitnami/git:2.42.1
|
||||
commands:
|
||||
- git log -1 --pretty=%B >> commitlint.txt
|
||||
|
||||
"lint:commitlint":
|
||||
group: lint
|
||||
image: node:lts-slim
|
||||
commands:
|
||||
- npm install --save-dev conventional-changelog-conventionalcommits @commitlint/config-conventional commitlint@latest
|
||||
- cat commitlint.txt
|
||||
- cat commitlint.txt | npx commitlint
|
||||
"lint:precommit":
|
||||
group: lint
|
||||
image: python:3.11.6-bullseye
|
||||
|
|
@ -18,13 +30,6 @@ steps:
|
|||
commands:
|
||||
- export HOME=/home/gitleaks
|
||||
- gitleaks detect
|
||||
"lint:commitlint":
|
||||
group: lint
|
||||
image: node:lts-slim
|
||||
commands:
|
||||
- npm install --save-dev conventional-changelog-conventionalcommits @commitlint/config-conventional commitlint@latest
|
||||
- "echo message: $CI_COMMIT_MESSAGE"
|
||||
- "echo $CI_COMMIT_MESSAGE | npx commitlint"
|
||||
when:
|
||||
- branch: [main, dev]
|
||||
event: push
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
when:
|
||||
branch: dev
|
||||
event: [push]
|
||||
clone:
|
||||
git:
|
||||
image: woodpeckerci/plugin-git
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ dependencies {
|
|||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.modulith:spring-modulith-starter-core")
|
||||
implementation("org.springframework.modulith:spring-modulith-starter-jpa")
|
||||
implementation("io.micrometer:micrometer-tracing-bridge-brave")
|
||||
runtimeOnly("com.h2database:h2")
|
||||
runtimeOnly("org.postgresql:postgresql")
|
||||
runtimeOnly("org.springframework.modulith:spring-modulith-actuator")
|
||||
runtimeOnly("org.springframework.modulith:spring-modulith-observability")
|
||||
|
|
@ -36,3 +38,5 @@ application {
|
|||
// Define the main class for the application.
|
||||
mainClass.set("com.opitzconsulting.demo.ci.app.App")
|
||||
}
|
||||
|
||||
springBoot { buildInfo() }
|
||||
|
|
|
|||
|
|
@ -4,18 +4,29 @@
|
|||
// </editor-fold>
|
||||
package com.opitzconsulting.demo.ci.app;
|
||||
|
||||
import static com.opitzconsulting.demo.ci.app.MessageUtils.getMessage;
|
||||
import static com.opitzconsulting.demo.ci.utilities.StringUtils.join;
|
||||
import static com.opitzconsulting.demo.ci.utilities.StringUtils.split;
|
||||
|
||||
import com.opitzconsulting.demo.ci.list.LinkedList;
|
||||
import org.apache.commons.text.WordUtils;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableWebSecurity
|
||||
@Configuration
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
LinkedList tokens;
|
||||
tokens = split(getMessage());
|
||||
String result = join(tokens);
|
||||
System.out.println(WordUtils.capitalize(result));
|
||||
SpringApplication.run(App.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests((authorize) -> authorize
|
||||
.requestMatchers("/actuator/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.authenticated());
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
management:
|
||||
server:
|
||||
port: 8099
|
||||
info:
|
||||
env:
|
||||
enabled: true
|
||||
git:
|
||||
mode: "full"
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: info,health,metrics
|
||||
|
|
@ -10,3 +10,8 @@ plugins {
|
|||
// Apply the java-library plugin for API and implementation separation.
|
||||
`java-library`
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
|
|
|||
24
version.sh
24
version.sh
|
|
@ -1,15 +1,15 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env 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_LAST_RELEASE_TAG=$(git describe --abbrev=0)
|
||||
CD_PATCH=$(git rev-list $CD_LAST_RELEASE_TAG..HEAD --count)
|
||||
CD_QUALIFIER=$(git rev-parse --short HEAD)
|
||||
CD_LAST_RELEASE_TAG=$(git tag -l --contains HEAD)
|
||||
CD_CURRENT_VERSION="${CD_BASE_VERSION}.${CD_PATCH}"
|
||||
CD_CURRENT_VERSION_QUALIFIED="${CD_BASE_VERSION}.${CD_PATCH}-${CD_QUALIFIER}"
|
||||
CD_NEXT_MAJOR_TAG=$(cut -d'.' -f1 <<< "${CD_BASE_VERSION}")
|
||||
CD_CURRENT_MAJOR_TAG=$(echo "${CD_BASE_VERSION}" | cut -d'.' -f1)
|
||||
|
||||
export CD_BASE_VERSION
|
||||
export CD_PATCH
|
||||
|
|
@ -17,14 +17,22 @@ export CD_QUALIFIER
|
|||
export CD_LAST_RELEASE_TAG
|
||||
export CD_CURRENT_VERSION
|
||||
export CD_CURRENT_VERSION_QUALIFIED
|
||||
export CD_NEXT_MAJOR_TAG
|
||||
export CD_CURRENT_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_CURRENT_VERSION}"
|
||||
echo "Next qualified Release Version: ${CD_CURRENT_VERSION_QUALIFIED}"
|
||||
echo "Current Release Version: ${CD_CURRENT_VERSION}"
|
||||
echo "Current qualified Release Version: ${CD_CURRENT_VERSION_QUALIFIED}"
|
||||
echo "BASE TAG: ${CD_BASE_VERSION}"
|
||||
echo "Next Major Release Tag: ${CD_NEXT_MAJOR_TAG}"
|
||||
echo "Current Major Release Tag: ${CD_CURRENT_MAJOR_TAG}"
|
||||
echo "Current Release Tag (normally get from pipeline CI_COMMIT_TAG): ${CD_RELEASE_TAG}"
|
||||
|
||||
echo "CD_BASE_VERSION=${CD_BASE_VERSION}" > version-lock.sh
|
||||
echo "CD_PATCH=${CD_PATCH}" >> version-lock.sh
|
||||
echo "CD_QUALIFIER=${CD_QUALIFIER}" >> version-lock.sh
|
||||
echo "CD_LAST_RELEASE_TAG=${CD_LAST_RELEASE_TAG}" >> version-lock.sh
|
||||
echo "CD_CURRENT_VERSION=${CD_CURRENT_VERSION}" >> version-lock.sh
|
||||
echo "CD_CURRENT_VERSION_QUALIFIED=${CD_CURRENT_VERSION_QUALIFIED}" >> version-lock.sh
|
||||
echo "CD_CURRENT_MAJOR_TAG=${CD_CURRENT_MAJOR_TAG}" >> version-lock.sh
|
||||
|
|
|
|||
Loading…
Reference in New Issue