-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from alexarchambault/publish
Publish individual indices on Maven Central
- Loading branch information
Showing
8 changed files
with
630 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: coursier/[email protected] | ||
- uses: coursier/[email protected] | ||
with: | ||
jvm: 11 | ||
- name: Publish local | ||
run: cd publish && ./mill -i __.publishLocal | ||
if: github.ref != 'refs/heads/master' | ||
env: | ||
PUBLISH_SECRET_KEY: ${{ secrets.PUBLISH_SECRET_KEY }} | ||
PUBLISH_SECRET_KEY_PASSWORD: ${{ secrets.PUBLISH_SECRET_KEY_PASSWORD }} | ||
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} | ||
PUBLISH_USER: ${{ secrets.PUBLISH_USER }} | ||
- run: echo "$PGP_SECRET" | base64 --decode | gpg --batch --import | ||
if: github.ref == 'refs/heads/master' | ||
env: | ||
PGP_SECRET: ${{ secrets.PUBLISH_SECRET_KEY }} | ||
- name: Publish | ||
run: cd publish && ./mill -i ci.publishSonatype --tasks __.publishArtifacts | ||
if: github.ref == 'refs/heads/master' | ||
env: | ||
PUBLISH_SECRET_KEY: ${{ secrets.PUBLISH_SECRET_KEY }} | ||
PUBLISH_SECRET_KEY_PASSWORD: ${{ secrets.PUBLISH_SECRET_KEY_PASSWORD }} | ||
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} | ||
PUBLISH_USER: ${{ secrets.PUBLISH_USER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
- uses: coursier/[email protected] | ||
with: | ||
jvm: 11 | ||
- run: ./scala-cli.sh compile . | ||
- run: ./scala-cli.sh compile src | ||
|
||
fmt: | ||
runs-on: ubuntu-latest | ||
|
@@ -24,4 +24,5 @@ jobs: | |
- uses: coursier/[email protected] | ||
with: | ||
jvm: 11 | ||
- run: ./scala-cli.sh fmt . --check | ||
apps: scalafmt | ||
- run: scalafmt --test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ jobs: | |
- uses: coursier/[email protected] | ||
with: | ||
jvm: 11 | ||
- run: ./scala-cli.sh . | ||
- run: ./scala-cli.sh src | ||
env: | ||
GH_TOKEN: ${{ secrets.INDEX_GITHUB_TOKEN }} | ||
- name: Create Pull Request | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.12.0-RC3-68-d5c638 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.bloop/ | ||
.bsp/ | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0` | ||
|
||
import de.tobiasroeser.mill.vcs.version.VcsVersion | ||
import mill._ | ||
import mill.api.WorkspaceRoot | ||
import mill.scalalib._ | ||
import mill.scalalib.publish._ | ||
|
||
import scala.concurrent.duration._ | ||
|
||
trait IndexModule extends Cross.Module[String] with PublishModule { | ||
def moduleName = s"index-$crossValue" | ||
def pomSettings = PomSettings( | ||
description = s"JVM index for $crossValue", | ||
organization = "io.get-coursier.jvm.indices", | ||
url = "https://github.com/coursier/jvm-index", | ||
licenses = Seq(License.`Apache-2.0`), | ||
versionControl = VersionControl.github("io.get-coursier", "jvm-index"), | ||
developers = Seq( | ||
Developer("alexarchambault", "Alex Archambault", "https://github.com/alexarchambault") | ||
) | ||
) | ||
def publishVersion = VcsVersion.vcsState().format() | ||
def sonatypeUri = "https://s01.oss.sonatype.org/service/local" | ||
def sonatypeSnapshotUri = "https://s01.oss.sonatype.org/content/repositories/snapshots" | ||
|
||
def indexFile = T.source { | ||
PathRef(T.workspace / os.up / "indices" / s"$crossValue.json") | ||
} | ||
|
||
def indexResourceDir = T { | ||
val dest = T.dest | ||
os.copy.over( | ||
indexFile().path, | ||
dest / "coursier/jvm/indices/v1" / s"$crossValue.json", | ||
createFolders = true | ||
) | ||
PathRef(dest) | ||
} | ||
|
||
def resources = T.sources( | ||
Seq(indexResourceDir()) | ||
) | ||
} | ||
|
||
lazy val osCpus = | ||
os.list(WorkspaceRoot.workspaceRoot / os.up / "indices") | ||
.filter(_.last.endsWith(".json")) | ||
.filter(os.isFile) | ||
.map(_.last.stripSuffix(".json")) | ||
|
||
object index extends Cross[IndexModule](osCpus) | ||
|
||
object ci extends Module { | ||
|
||
// same publishing stuff I copy-paste in all my projects 😬 | ||
|
||
private def publishSonatype0( | ||
credentials: String, | ||
pgpPassword: String, | ||
data: Seq[PublishModule.PublishData], | ||
timeout: Duration, | ||
log: mill.api.Logger | ||
): Unit = { | ||
|
||
val artifacts = data.map { | ||
case PublishModule.PublishData(a, s) => | ||
(s.map { case (p, f) => (p.path, f) }, a) | ||
} | ||
|
||
val isRelease = { | ||
val versions = artifacts.map(_._2.version).toSet | ||
val set = versions.map(!_.endsWith("-SNAPSHOT")) | ||
assert( | ||
set.size == 1, | ||
s"Found both snapshot and non-snapshot versions: ${versions.toVector.sorted.mkString(", ")}" | ||
) | ||
set.head | ||
} | ||
val publisher = new SonatypePublisher( | ||
uri = "https://s01.oss.sonatype.org/service/local", | ||
snapshotUri = "https://s01.oss.sonatype.org/content/repositories/snapshots", | ||
credentials = credentials, | ||
signed = isRelease, | ||
gpgArgs = Seq( | ||
"--passphrase", | ||
pgpPassword, | ||
"--no-tty", | ||
"--pinentry-mode", | ||
"loopback", | ||
"--batch", | ||
"--yes", | ||
"-a", | ||
"-b" | ||
), | ||
readTimeout = timeout.toMillis.toInt, | ||
connectTimeout = timeout.toMillis.toInt, | ||
log = log, | ||
workspace = os.pwd, | ||
env = sys.env, | ||
awaitTimeout = timeout.toMillis.toInt, | ||
stagingRelease = isRelease | ||
) | ||
|
||
publisher.publishAll(isRelease, artifacts: _*) | ||
} | ||
|
||
def publishSonatype(tasks: mill.main.Tasks[PublishModule.PublishData]) = | ||
T.command { | ||
val timeout = 10.minutes | ||
val credentials = sys.env("PUBLISH_USER") + ":" + sys.env("PUBLISH_PASSWORD") | ||
val pgpPassword = sys.env("PUBLISH_SECRET_KEY_PASSWORD") | ||
val data = T.sequence(tasks.value)() | ||
|
||
publishSonatype0( | ||
credentials = credentials, | ||
pgpPassword = pgpPassword, | ||
data = data, | ||
timeout = timeout, | ||
log = T.ctx().log | ||
) | ||
} | ||
} |
Oops, something went wrong.