This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-all-in-one.groovy
82 lines (71 loc) · 3.04 KB
/
publish-all-in-one.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
pipeline {
agent any
tools {
jdk 'temurin-jdk17-latest'
}
stages {
stage("init") {
steps {
script {
currentBuild.displayName = sh(script: 'echo "$VERSION"', returnStdout: true).trim()
}
}
}
stage("clone-repo") {
steps {
cleanWs()
git(branch: "main", url: "https://github.com/eclipse-edc/Release.git")
}
}
stage("setup-credentials") {
steps {
withCredentials([file(credentialsId: 'secret-subkeys.asc', variable: 'KEYRING'), string(credentialsId: 'gpg-passphrase', variable: 'PASSPHRASE'), usernamePassword(credentialsId: 'ossrh-account', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USER')]) {
sh '''
echo $KEYRING
gpg --batch --import "${KEYRING}"
for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u);
do
echo -e "5\\ny\\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done
'''
sh '''
# we don't have a TTY, so we need to use the loopback mode
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo "no-tty" >> ~/.gnupg/gpg.conf
'''
}
}
}
stage("prepare") {
steps {
echo "Prepare build with version $VERSION"
sh './prepare.sh'
}
}
stage("publish") {
steps {
withCredentials([string(credentialsId: 'gpg-passphrase', variable: 'PASSPHRASE'), usernamePassword(credentialsId: 'ossrh-account', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USER')]) {
sh '''
echo "Will build release with version $VERSION"
echo "JAVA_HOME: ${JAVA_HOME}. Java --version:"
java --version
cmd=""
versionProp=""
if [ ! -z "$VERSION" ]
then
# set the version property if a version was specified, use defaults otherwise
versionProp="-Pversion=$VERSION"
# if the version doesn't end with -SNAPSHOT we need to handle staging/releasing
if [[ $VERSION != *-SNAPSHOT ]]
then
cmd="closeAndReleaseSonatypeStagingRepository";
fi
fi
./gradlew publishToSonatype ${cmd} -Psigning.gnupg.keyName=1B4555CF -Psigning.gnupg.passphrase=${PASSPHRASE} -Psigning.gnupg.executable=gpg --no-parallel ${versionProp}
'''
}
}
}
}
}