From b9e38b0584b22e693f684b931c773fc77c7d2a8a Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Thu, 30 Jun 2022 02:07:42 +0200 Subject: [PATCH] feat: implement new CI workflow --- .gitlab-ci.yml | 84 ++++++++++++++++++++++++++++----------- .husky/prepare-commit-msg | 4 ++ CHANGELOG.md | 4 ++ CONTRIBUTORS.md | 5 +++ RELEASE.md | 4 +- oaipmh-core/pom.xml | 2 +- oaipmh-webapp/pom.xml | 2 +- package.json | 65 ++++++++++++++++++++++++++++++ pom.xml | 28 ++++++++++--- 9 files changed, 165 insertions(+), 33 deletions(-) create mode 100644 .husky/prepare-commit-msg create mode 100644 CONTRIBUTORS.md create mode 100644 package.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d55c62e..af60732d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,28 +5,33 @@ # Some variables # TODO: Apply also as a template! variables: - # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log. - # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. + # Maven Settings MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" - # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used - # when running from the command line. - #MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" - # Nexus Deployment settings, please use env vars in Settings -> CI/CD -> Variables. + # Maven deployment settings for Nexus, please use env vars in Settings -> CI/CD -> Variables. MAVEN_SETTINGS_PATH: ".m2/settings.xml" MAVEN_DEPLOY_OPTS: "--settings=$MAVEN_SETTINGS_PATH" + # Semantic versioning commit and push vars (the TOKEN name and user) + GIT_AUTHOR_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de + GIT_AUTHOR_NAME: ${GL_USER} + GIT_COMMITTER_EMAIL: ${GL_USER}@noreply.gitlab.gwdg.de + GIT_COMMITTER_NAME: ${GL_USER} # Include Java settings from Gitlab templates repo. include: - project: 'dariah-de/gitlab-templates' ref: 'main' file: '/templates/.java.gitlab-ci.yml' + - project: 'dariah-de/gitlab-templates' + ref: 'main' + file: '/templates/SBOM-Upload.gitlab-ci.yml' # Stages... stages: - - build_version - - deploy_java - - deploy_deb + - prepare + - test + - build + - deploy # Cache downloaded dependencies and plugins between builds. # To keep cache across branches add 'key: "$CI_JOB_NAME"' @@ -40,31 +45,63 @@ cache: ### # Get the project version from main POM file and store it to artifact. -Get POM version: +get-pom-version: + stage: prepare only: - develop - - main - stage: build_version + - tags extends: - .get-pom-version-to-env +# Semantic versioning: Update POM and CHANGELOG RELEASE files, TAG a new RELEASE version! +prepare-release: + stage: prepare + rules: + # Only run if branch "main" AND commit title IS NOT "1.2.3" (main commit with tag) AND DOES NOT START WITH "Prepare next development iteration" (main commit with new version) + - if: $CI_COMMIT_REF_NAME == "main" && $CI_COMMIT_TITLE !~ /^[\d\.]+$/ && $CI_COMMIT_TITLE !~ /^Prepare next development iteration/ + image: maven:3.8.3-jdk-8 + extends: + - .prepare-semantic-release + +# Build, validate, and package all the feature branches +validate-java: + stage: test + except: + - main + - develop + - tags + image: maven:3.8.3-jdk-8 + script: + - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean validate package -Pdhrep.deb + artifacts: + reports: + # Declare the JUnit reports (recursive pattern for multi-module projects) + junit: + - "**/target/*-reports/TEST-*.xml" + # Build and deploy all the JARs to GWDG Nexus, and build all the DEBs and store DEBs to artifacts. -Build and Deploy JARs: +# NOTE: "deploy" also triggers BOM creation! +build-and-deploy-jars: + stage: build image: maven:3.8.3-jdk-8 only: - develop - - main - stage: deploy_java + - tags script: - - 'mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy -Pdhrep.deb' + - mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy -Pdhrep.deb + - cp target/bom.json . artifacts: - name: WEBAPP_DEB_PACKAGES paths: - ./oaipmh-webapp/target/*.deb + - ./bom.json + reports: + # Declare the JUnit reports (recursive pattern for multi-module projects) + junit: + - "**/target/*-reports/TEST-*.xml" -# Deploy DEB files to APTLY repository. -Deploy SNAPSHOT DEB: - stage: deploy_deb +# Deploy DEB files to APTLY SNAPSHOT repository. +deploy-snapshot-deb: + stage: deploy only: - develop variables: @@ -75,10 +112,11 @@ Deploy SNAPSHOT DEB: extends: - .deploy-deb -Deploy RELEASE DEB: - stage: deploy_deb +# Deploy DEB files to APTLY RELEASE repository. +deploy-release-deb: + stage: deploy only: - - main + - tags variables: PNAME: 'oaipmh-webapp' PPATH: '${PNAME}/target' diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100644 index 00000000..17e2764c --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +exec < /dev/tty && npx cz --hook || true diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a5ddf22..30756fba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 4.2.10-SNAPSHOT + +* Implement new CI workflow + # 4.2.8 * Fix #61 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..e8fa9e98 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +# Contributors to DARIAH-DE OAI-PMH Services + +* Maximilian Behnert-Brodhun +* Stefan E. Funk +* Ubbo Veentjer diff --git a/RELEASE.md b/RELEASE.md index 02ed5d9a..81ccda00 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,3 +1,3 @@ -For releasing a new version, please have a look at the [DARIAH-DE Release Management Page] (https://wiki.de.dariah.eu/display/DARIAH3/DARIAH-DE+Release+Management). +# Releasing a new version -Please set the **SNAPSHOT** version to `x.y.z-SNAPSHOT` and the **RELEASE** version to `x.y.z`! +For releasing a new version of DARIAH-DE OAI-PMH, please have a look at the [DARIAH-DE Release Management Page](https://wiki.de.dariah.eu/display/DARIAH3/DARIAH-DE+Release+Management#DARIAHDEReleaseManagement-Gitlabflow/Gitflow(develop,main,featurebranchesundtags)) or see the [Gitlab CI file](.gitlab-ci.yml). diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index a17ceb26..4f341b4f 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>4.2.10-SNAPSHOT</version> + <version>4.3.0-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index 99a30e22..f6001715 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>4.2.10-SNAPSHOT</version> + <version>4.3.0-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> diff --git a/package.json b/package.json new file mode 100644 index 00000000..fd4cde0a --- /dev/null +++ b/package.json @@ -0,0 +1,65 @@ +{ + "private": true, + "name": "dariah-de-oaipmh-services", + "description": "The source code and deployment workflows for the DARIAH-DE OAI-PMH Services used for the TextGrid and the DARIAH-DE Repositories", + "scripts": { + "prepare": "husky install" + }, + "repository": { + "type": "git", + "url": "https://gitlab.gwdg.de/dariah-de/dariah-de-crud-services" + }, + "devDependencies": { + "@conveyal/maven-semantic-release": "^5.0.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/git": "^10.0.1", + "@semantic-release/gitlab": "^7.0.4", + "cz-conventional-changelog": "^3.0.1", + "husky": "^7.0.4", + "semantic-release": "^19.0.2" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + }, + "release": { + "branches": [ + "main" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + "@conveyal/maven-semantic-release", + [ + "@semantic-release/gitlab", + { + "gitlabUrl": "https://gitlab.gwdg.de", + "assets": [ + { + "path": "CHANGELOG.md", + "label": "Changelog" + } + ] + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ] + } + ] + ] + }, + "dependencies": { + "commitizen": "^4.2.4" + } +} diff --git a/pom.xml b/pom.xml index d2d46a3f..c2e3bb77 100644 --- a/pom.xml +++ b/pom.xml @@ -4,17 +4,17 @@ <modelVersion>4.0.0</modelVersion> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh</artifactId> - <version>4.2.10-SNAPSHOT</version> + <version>4.3.0-SNAPSHOT</version> <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <cxf.version>3.3.13</cxf.version> - <jdk.version>1.8</jdk.version> - <antlr-maven-plugin.version>3.2</antlr-maven-plugin.version> + <jdk.version>1.8</jdk.version> + <antlr-maven-plugin.version>3.2</antlr-maven-plugin.version> <antlr-runtime.version>3.2</antlr-runtime.version> - <common.version>4.2.0-SNAPSHOT</common.version> - <cxf.version>3.3.12</cxf.version> + <common.version>4.4.0</common.version> + <cxf.version>3.3.13</cxf.version> + <cyclonedx-maven-plugin.version>2.7.0</cyclonedx-maven-plugin.version> <elasticsearch.version>6.5.4</elasticsearch.version> <jaxb2-namespace-prefix.version>1.3</jaxb2-namespace-prefix.version> <jetty-maven-plugin.version>9.4.12.v20180830</jetty-maven-plugin.version> @@ -83,6 +83,22 @@ <artifactId>maven-deploy-plugin</artifactId> <version>${maven-deploy-plugin.version}</version> </plugin> + <plugin> + <groupId>org.cyclonedx</groupId> + <artifactId>cyclonedx-maven-plugin</artifactId> + <version>${cyclonedx-maven-plugin.version}</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>makeAggregateBom</goal> + </goals> + </execution> + </executions> + <configuration> + <outputFormat>JSON</outputFormat> + </configuration> + </plugin> </plugins> </build> <modules> -- GitLab