Skip to content

Commit 4807fb8

Browse files
Merge pull request #110 from whitesource/OPS-5172
[OPS-5172] added snapshot and release workflows
2 parents 207e58a + 95a75a3 commit 4807fb8

File tree

3 files changed

+150
-1
lines changed

3 files changed

+150
-1
lines changed

.github/workflows/release.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: "Release version"
8+
required: true
9+
default: "2.9.9.99"
10+
nextDevVersion:
11+
description: "Next development version (must end with -SNAPSHOT)"
12+
required: true
13+
default: "2.9.9.100-SNAPSHOT"
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Set up JDK 8
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: "8"
32+
distribution: "temurin"
33+
server-id: sonatype-nexus-staging
34+
server-username: ${{ secrets.OSSRH_USERNAME }}
35+
server-password: ${{ secrets.OSSRH_TOKEN }}
36+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
37+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
38+
39+
- name: Configure Git
40+
run: |
41+
git config user.email "hudson@whitesourcesoftware.com"
42+
git config user.name "whitesource-ci"
43+
# Configure Git to use HTTPS instead of SSH
44+
git config --global url."https://x-access-token:${{ github.token }}@github.com/".insteadOf "git@github.com:"
45+
46+
- name: Configure GPG
47+
run: |
48+
mkdir -p ~/.gnupg
49+
chmod 700 ~/.gnupg
50+
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
51+
echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
52+
53+
- name: Create Maven settings.xml
54+
run: |
55+
mkdir -p ~/.m2
56+
echo "<settings>
57+
<servers>
58+
<server>
59+
<id>sonatype-nexus-staging</id>
60+
<username>${{ secrets.OSSRH_USERNAME }}</username>
61+
<password>${{ secrets.OSSRH_TOKEN }}</password>
62+
</server>
63+
</servers>
64+
<profiles>
65+
<profile>
66+
<id>gpg-settings</id>
67+
<properties>
68+
<gpg.executable>gpg</gpg.executable>
69+
<gpg.passphrase>${{ secrets.GPG_PASSPHRASE }}</gpg.passphrase>
70+
</properties>
71+
</profile>
72+
</profiles>
73+
<activeProfiles>
74+
<activeProfile>gpg-settings</activeProfile>
75+
</activeProfiles>
76+
</settings>" > ~/.m2/settings.xml
77+
78+
- name: Maven Release
79+
run: |
80+
export GPG_TTY=$(tty)
81+
mvn -B -DsourceLevel=1.8 -Djava.version=1.8 \
82+
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
83+
-DdevelopmentVersion=${{ github.event.inputs.nextDevVersion }} \
84+
-DscmCommentPrefix="[maven-release-plugin] [skip ci] " \
85+
-Darguments="-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Pci-build -PRelease" \
86+
release:clean release:prepare release:perform
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/snapshot.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- "**/*.md"
9+
10+
jobs:
11+
deploy-snapshot:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: "8"
21+
distribution: "temurin"
22+
server-id: sonatype-nexus-snapshots
23+
server-username: ${{ secrets.OSSRH_USERNAME }}
24+
server-password: ${{ secrets.OSSRH_TOKEN }}
25+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
26+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
27+
28+
- name: Create Maven settings.xml
29+
run: |
30+
mkdir -p ~/.m2
31+
echo "<settings>
32+
<servers>
33+
<server>
34+
<id>sonatype-nexus-snapshots</id>
35+
<username>${{ secrets.OSSRH_USERNAME }}</username>
36+
<password>${{ secrets.OSSRH_TOKEN }}</password>
37+
</server>
38+
</servers>
39+
</settings>" > ~/.m2/settings.xml
40+
41+
- name: Verify SNAPSHOT version
42+
run: |
43+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
44+
if [[ $VERSION != *"-SNAPSHOT" ]]; then
45+
echo "Error: Version must be a SNAPSHOT"
46+
exit 1
47+
fi
48+
49+
- name: Build and deploy
50+
run: mvn -B clean deploy -Pci-build

pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@
243243
</reportPlugins>
244244
</configuration>
245245
</plugin>
246+
<plugin>
247+
<groupId>org.sonatype.plugins</groupId>
248+
<artifactId>nexus-staging-maven-plugin</artifactId>
249+
<version>1.6.13</version>
250+
<extensions>true</extensions>
251+
<configuration>
252+
<serverId>sonatype-nexus-staging</serverId>
253+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
254+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
255+
</configuration>
256+
</plugin>
246257
</plugins>
247258
<pluginManagement>
248259
<plugins>
@@ -286,7 +297,6 @@
286297
<groupId>org.apache.maven.plugins</groupId>
287298
<artifactId>maven-release-plugin</artifactId>
288299
<version>2.5.3</version>
289-
290300
</plugin>
291301
<plugin>
292302
<groupId>com.mycila.maven-license-plugin</groupId>

0 commit comments

Comments
 (0)