Skip to content

Commit f20ff03

Browse files
committed
Fake release testing
1 parent 53d9d51 commit f20ff03

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

.github/workflows/publish_assets.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ jobs:
107107
uses: ./.github/actions/extract-1password-secret
108108
with:
109109
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} # This is required to connect to the vault in our 1Password account.
110-
VARIABLES_TO_EXTRACT: 'MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, SONATYPE_TOKEN_USERNAME, SONATYPE_TOKEN_PASSWORD'
110+
VARIABLES_TO_EXTRACT: 'MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME, MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD'
111111
ONE_PASSWORD_SECRET_REFERENCES: ${{ vars.ONE_PASSWORD_SECRET_REFERENCES }}
112112

113113
- name: Build and Publish to Sonatype
114114
run: |
115115
# Don't verify since it has already been done when the PR was created.
116116
./gradlew publish --rerun-tasks -x spotlessCheck
117+
./gradlew customPublish
117118

build.gradle

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
* A note about publishing and signing.
1818
* Maven central requires that artifacts be signed. And upload is done to Sonatype.
1919
* To publish you will need these environment variables defined:
20-
* SONATYPE_TOKEN_USERNAME
21-
* SONATYPE_TOKEN_PASSWORD
2220
* MAVEN_GPG_PRIVATE_KEY
2321
* MAVEN_GPG_PASSPHRASE
2422
* Suggestion is to put these in a shell script with restricted read permissions, then source it before calling
@@ -37,11 +35,11 @@ plugins {
3735

3836
// Setup and configure properties that are consistent across all projects, including sub-modules.
3937
allprojects {
40-
group 'io.github.jcpitre.gtfs-validator-trial'
38+
group 'org.mobilitydata.gtfs-validator'
4139

4240
// Per the axion-release plugin, this computes the project version based
4341
// on the most recent tag in the repo.
44-
version 1.3
42+
version "0.3"
4543

4644
repositories {
4745
mavenCentral()
@@ -59,6 +57,7 @@ allprojects {
5957

6058
tasks.withType(Javadoc) {
6159
options.encoding = 'UTF-8'
60+
options.addStringOption('Xdoclint:none', '-quiet')
6261
}
6362

6463
// All projects that include the 'java` plugin will have a Test task by default.
@@ -83,16 +82,6 @@ subprojects {
8382
apply plugin: 'java'
8483
apply plugin: libs.plugins.spotless.get().pluginId
8584

86-
// Cannot publish a SNAPSHOT. The provided sonatype url will not accept it.
87-
tasks.withType(PublishToMavenRepository).all { task ->
88-
task.onlyIf {
89-
if (project.version.toString().contains('SNAPSHOT')) {
90-
throw new GradleException("Publishing is not allowed for SNAPSHOT versions. Currently " + project.version)
91-
}
92-
true
93-
}
94-
}
95-
9685
task javadocJar(type: Jar) {
9786
archiveClassifier.set('javadoc')
9887
from javadoc
@@ -126,12 +115,15 @@ subprojects {
126115
// Once successfully closed, the repo is available for testing.
127116
// After testing, it can be manually promoted on the sonatype site, which will then publish to maven central.
128117
maven {
129-
url = "${buildDir}/local-repo"
130-
// url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
131-
// credentials {
132-
// username System.getenv("SONATYPE_TOKEN_USERNAME")
133-
// password System.getenv("SONATYPE_TOKEN_PASSWORD")
134-
// }
118+
if (version.endsWith('SNAPSHOT')) {
119+
url = 'https://central.sonatype.com/repository/maven-snapshots/'
120+
credentials {
121+
username = System.getenv("MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME")
122+
password = System.getenv("MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD")
123+
}
124+
} else {
125+
url = "${buildDir}/local-repo"
126+
}
135127
}
136128
}
137129

@@ -174,16 +166,33 @@ subprojects {
174166
useInMemoryPgpKeys(System.getenv('MAVEN_GPG_PRIVATE_KEY'), System.getenv('MAVEN_GPG_PASSPHRASE'))
175167
sign publishing.publications.mavenJava
176168
}
169+
170+
171+
// tasks.named('publish') {
172+
// finalizedBy customPublish
173+
// }
177174
}
178175
task customPublish {
179-
dependsOn publish
176+
// dependsOn publishMavenJavaPublicationToMavenRepository
177+
// mustRunAfter publish
178+
onlyIf {
179+
if (project.version.toString().contains('SNAPSHOT')) {
180+
throw new GradleException("Publishing to Maven Central Portal is not allowed for SNAPSHOT versions. Currently " + project.version)
181+
}
182+
return true
183+
}
184+
180185
doLast {
181186
exec {
187+
println "Current working directory: ${project.file('.').absolutePath}"
182188
commandLine 'bash', "../scripts/custom_publish.sh", project.name, project.version
183189
}
184190
}
185191
}
192+
193+
186194
}
195+
187196
compileJava {
188197
options.compilerArgs << '-parameters'
189198
}

scripts/custom_publish.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -x
2+
#set -x
33

44
subproject=$1
55
version=$2
@@ -11,10 +11,13 @@ echo "subproject = $subproject"
1111
zipfile=${subproject}.${version}.zip
1212

1313
pushd build/local-repo
14-
zip -r ${zipfile} io
14+
zip -qr ${zipfile} *
1515

1616
bearer_token=$(echo "$MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME:$MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD" | base64)
1717

18+
#echo "Time to call curl ~~~~~~~~~~~~~~~~~"
19+
#exit 0
20+
1821
answer=$(curl --request POST \
1922
--verbose \
2023
--header "Authorization: Bearer ${bearer_token}" \

0 commit comments

Comments
 (0)