Skip to content

Commit ca155d3

Browse files
authored
[OP-32198] Introduce GHA (#114)
1 parent 25924fe commit ca155d3

File tree

10 files changed

+146
-74
lines changed

10 files changed

+146
-74
lines changed

.circleci/config.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'Setup Maven'
2+
description: 'Installs maven and provides secrets'
3+
inputs:
4+
java-version:
5+
description: 'The Java version to use'
6+
required: true
7+
type: string
8+
maven-version:
9+
description: 'The Maven version to use'
10+
required: true
11+
type: string
12+
sonatype-username:
13+
description: 'The SONATYPE username'
14+
required: true
15+
type: string
16+
sonatype-password:
17+
description: 'The SONATYPE password'
18+
required: true
19+
type: string
20+
runs:
21+
using: 'composite'
22+
steps:
23+
- name: Setup Maven Action
24+
uses: s4u/setup-maven-action@v1.18.0
25+
with:
26+
java-version: ${{ inputs.java-version }}
27+
maven-version: ${{ inputs.maven-version }}
28+
- shell: bash
29+
run: |
30+
mkdir -p $HOME/.m2
31+
cp .github/settings.xml $HOME/.m2/settings.xml
32+
sed -i "s|\${SONATYPE_USERNAME}|${{ inputs.sonatype-username }}|g" $HOME/.m2/settings.xml
33+
sed -i "s|\${SONATYPE_PASSWORD}|${{ inputs.sonatype-password }}|g" $HOME/.m2/settings.xml
34+
cat $HOME/.m2/settings.xml
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
44
<servers>
55
<server>
6-
<id>ossrh</id>
7-
<username>${OSSRH_USERNAME}</username>
8-
<password>${OSSRH_PASSWORD}</password>
6+
<id>central</id>
7+
<username>${SONATYPE_USERNAME}</username>
8+
<password>${SONATYPE_PASSWORD}</password>
99
</server>
1010
</servers>
1111
</settings>

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
test:
8+
uses: ./.github/workflows/test.yml
9+
secrets: inherit

.github/workflows/deploy.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
GPG_PASSPHRASE:
7+
required: true
8+
description: 'The GPG passphrase'
9+
SONATYPE_USERNAME:
10+
required: true
11+
description: 'The SONATYPE username'
12+
SONATYPE_PASSWORD:
13+
required: true
14+
description: 'The SONATYPE password'
15+
16+
jobs:
17+
deploy:
18+
runs-on: k8s-runner-linux
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: ./.github/actions/setup-maven
22+
with:
23+
java-version: '8'
24+
maven-version: '3.6.3'
25+
sonatype-username: ${{ secrets.SONATYPE_USERNAME }}
26+
sonatype-password: ${{ secrets.SONATYPE_PASSWORD }}
27+
- env:
28+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
29+
run: |
30+
./gen-gpg-key.sh
31+
sed -i "s/\${GPG_PASSPHRASE}/$GPG_PASSPHRASE/g" ./pom.xml
32+
cat ./pom.xml
33+
name: Generate GPG key
34+
- name: Deploy
35+
run: mvn deploy -Prelease -X

.github/workflows/tag.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
deploy:
10+
uses: ./.github/workflows/deploy.yml
11+
secrets: inherit

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
SONATYPE_USERNAME:
7+
required: true
8+
description: 'The SONATYPE username'
9+
SONATYPE_PASSWORD:
10+
required: true
11+
description: 'The SONATYPE password'
12+
13+
jobs:
14+
build:
15+
runs-on: k8s-runner-linux
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: ./.github/actions/setup-maven
19+
with:
20+
java-version: '8'
21+
maven-version: '3.6.3'
22+
sonatype-username: ${{ secrets.SONATYPE_USERNAME }}
23+
sonatype-password: ${{ secrets.SONATYPE_PASSWORD }}
24+
- run: mvn verify

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ target
66
.classpath
77
.project
88
.settings/
9-
zephyrscale_result.json
9+
zephyrscale_result.json
10+
.vscode

gen-gpg-key.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22

3+
if [[ -z "$GPG_PASSPHRASE" ]]; then
4+
echo "GPG_PASSPHRASE is not set. Please set it before running this script."
5+
exit 1
6+
fi
7+
38
gpg --batch --gen-key <<EOF
49
Key-Type: 1
510
Key-Length: 2048
@@ -8,7 +13,12 @@ Subkey-Length: 2048
813
Name-Real: zephyrscale
914
Name-Email: svc_zephyr_scale@smartbear.com
1015
Expire-Date: 0
11-
Passphrase: ${GPG_PASSPHRASE}
16+
Passphrase: $GPG_PASSPHRASE
1217
EOF
1318

14-
gpg --keyserver hkps://keys.openpgp.org --send-keys $(gpg --with-colons --fingerprint | awk -F: '$1 == "fpr" {print $10;}')
19+
FINGERPRINT=$(gpg --with-colons --fingerprint | awk -F: '$1 == "fpr" {print $10;}')
20+
if [[ -z "$FINGERPRINT" ]]; then
21+
echo "No GPG key fingerprint found. Please check if the key was generated successfully."
22+
exit 1
23+
fi
24+
gpg --keyserver hkps://keys.openpgp.org --send-keys $FINGERPRINT

pom.xml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.smartbear</groupId>
88
<artifactId>zephyrscale-junit-integration</artifactId>
9-
<version>2.0.1</version>
9+
<version>2.0.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Zephyr Scale JUnit Integration</name>
@@ -89,6 +89,15 @@
8989
</gpgArguments>
9090
</configuration>
9191
</plugin>
92+
<plugin>
93+
<groupId>org.sonatype.central</groupId>
94+
<artifactId>central-publishing-maven-plugin</artifactId>
95+
<version>0.7.0</version>
96+
<extensions>true</extensions>
97+
<configuration>
98+
<publishingServerId>central</publishingServerId>
99+
</configuration>
100+
</plugin>
92101
</plugins>
93102
</build>
94103
</profile>
@@ -117,7 +126,9 @@
117126
<execution>
118127
<id>attach-sources</id>
119128
<phase>package</phase>
120-
<goals><goal>jar-no-fork</goal></goals>
129+
<goals>
130+
<goal>jar-no-fork</goal>
131+
</goals>
121132
</execution>
122133
</executions>
123134
</plugin>
@@ -129,21 +140,15 @@
129140
<execution>
130141
<id>attach-javadocs</id>
131142
<phase>package</phase>
132-
<goals><goal>jar</goal></goals>
143+
<goals>
144+
<goal>jar</goal>
145+
</goals>
133146
</execution>
134147
</executions>
135148
</plugin>
136149
</plugins>
137150
</build>
138151

139-
<distributionManagement>
140-
<repository>
141-
<id>ossrh</id>
142-
<name>Sonatype OSSRH Repository</name>
143-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
144-
</repository>
145-
</distributionManagement>
146-
147152
<properties>
148153
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
149154
</properties>

0 commit comments

Comments
 (0)