From 27b3b668d3c0327c146fc0f103ac65450a256d32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jari-Matti=20M=C3=A4kel=C3=A4?= <jmjmak@utu.fi>
Date: Wed, 6 Mar 2024 19:15:23 +0200
Subject: [PATCH] CI deployment

---
 .gitlab-ci.yml  | 30 ++++++++++++++++++++++++++++++
 ci_settings.xml | 16 ++++++++++++++++
 pom.xml         | 35 +++++++++++++++++++++++++----------
 3 files changed, 71 insertions(+), 10 deletions(-)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 ci_settings.xml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..8d8e64e0
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,30 @@
+image: maven:3-eclipse-temurin-17
+
+variables:
+  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"
+  MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end"
+
+cache:
+  key: "$CI_JOB_NAME"
+  paths:
+    - .m2/repository
+
+stages:
+  - build
+  - deploy
+
+# just check that it builds
+build:
+  stage: build
+  rules:
+    - if: '$CI_COMMIT_TAG == null'
+  script:
+    - mvn install -s ci_settings.xml
+
+# deploy the maven packages
+deploy:
+  stage: deploy
+  rules:
+    - if: $CI_COMMIT_TAG
+  script:
+    - mvn deploy -s ci_settings.xml
diff --git a/ci_settings.xml b/ci_settings.xml
new file mode 100644
index 00000000..59c8c271
--- /dev/null
+++ b/ci_settings.xml
@@ -0,0 +1,16 @@
+<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
+  <servers>
+    <server>
+      <id>gitlab-maven</id>
+      <configuration>
+        <httpHeaders>
+          <property>
+            <name>Job-Token</name>
+            <value>${env.CI_JOB_TOKEN}</value>
+          </property>
+        </httpHeaders>
+      </configuration>
+    </server>
+  </servers>
+</settings>
diff --git a/pom.xml b/pom.xml
index e6b44fce..3e79ee17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,7 @@
         <module>commonmark-ext-heading-anchor</module>
         <module>commonmark-ext-image-attributes</module>
         <module>commonmark-ext-ins</module>
+        <module>commonmark-ext-notifications</module>
         <module>commonmark-ext-task-list-items</module>
         <module>commonmark-ext-yaml-front-matter</module>
         <module>commonmark-integration-test</module>
@@ -77,9 +78,22 @@
                     <artifactId>maven-surefire-plugin</artifactId>
                     <version>2.22.2</version>
                 </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>3.2.1</version>
+                    <executions>
+                        <execution>
+                            <id>attach-sources</id>
+                            <goals>
+                                <goal>jar-no-fork</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
             </plugins>
         </pluginManagement>
-
+<!--
         <plugins>
             <plugin>
                 <groupId>org.sonatype.plugins</groupId>
@@ -105,6 +119,7 @@
                 </configuration>
             </plugin>
         </plugins>
+-->
     </build>
 
     <dependencyManagement>
@@ -179,7 +194,7 @@
             </dependency>
         </dependencies>
     </dependencyManagement>
-
+<!--
     <profiles>
         <profile>
             <id>release</id>
@@ -223,7 +238,7 @@
                                 </goals>
                                 <configuration>
                                     <gpgArguments>
-                                        <arg>--pinentry-mode</arg>
+                                        <arg>- -pinentry-mode</arg>
                                         <arg>loopback</arg>
                                     </gpgArguments>
                                 </configuration>
@@ -243,7 +258,6 @@
                         <version>0.8.8</version>
                         <configuration>
                             <excludes>
-                                <!-- Classes from test-util -->
                                 <exclude>org/commonmark/spec/*</exclude>
                                 <exclude>org/commonmark/test/*</exclude>
                             </excludes>
@@ -285,16 +299,17 @@
         <url>https://github.com/commonmark/commonmark-java</url>
         <tag>HEAD</tag>
     </scm>
+-->
 
     <distributionManagement>
-        <snapshotRepository>
-            <id>ossrh</id>
-            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-        </snapshotRepository>
         <repository>
-            <id>ossrh</id>
-            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+            <id>gitlab-maven</id>
+            <url>${env.CI_API_V4_URL}/projects/${env.CI_PROJECT_ID}/packages/maven</url>
         </repository>
+        <snapshotRepository>
+            <id>gitlab-maven</id>
+            <url>${env.CI_API_V4_URL}/projects/${env.CI_PROJECT_ID}/packages/maven</url>
+        </snapshotRepository>
     </distributionManagement>
 
 </project>
-- 
GitLab