Skip to content

Commit

Permalink
build: Publish snapshots (#4335)
Browse files Browse the repository at this point in the history
* build: Publish snapshots

* and publish docs with new ssh key

* email on failure

* remove comment

* determineLatestSnapshot from snapshot doc version
  • Loading branch information
patriknw authored Nov 8, 2023
1 parent b116a31 commit f429383
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- JDK_VERSION: 1.17
JVM_NAME: temurin:1.17
extraOpts: ''
AKKA_VERSION: [main, default]
AKKA_VERSION: [main, default, snapshot]

steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-test-reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
publish-test-results:
name: "Publish details with dorny-test-reporter"
runs-on: ubuntu-22.04
if: github.event.repository.fork == false
strategy:
fail-fast: false
matrix:
Expand Down
50 changes: 43 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
publish-artifacts:
name: Publish artifacts
runs-on: ubuntu-22.04
if: github.event.repository.fork == false
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -38,25 +39,60 @@ jobs:
PUBLISH_USER: ${{ secrets.PUBLISH_USER }}
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }}

- name: Email on failure
if: ${{ failure() }}
uses: dawidd6/action-send-mail@6063705cefe50cb915fc53bb06d4049cae2953b2
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: "Failed: ${{ github.workflow }} / ${{ github.job }}"
to: ${{secrets.MAIL_SEND_TO}}
from: Akka CI
body: |
Job ${{ github.job }} in workflow ${{ github.workflow }} of ${{github.repository}} failed!
https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
publish-docs:
name: Publish documentation
runs-on: ubuntu-22.04
if: github.event.repository.fork == false
steps:
- name: Checkout
uses: actions/[email protected]
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0

- name: Cache Coursier cache
uses: coursier/[email protected]

- name: Set up JDK 11
uses: coursier/[email protected]
with:
jvm: temurin:1.11

- name: Publish Documentation
run: |
eval "$(ssh-agent -s)" && echo $SCP_SECRET | base64 -d > /tmp/id_rsa && chmod 600 /tmp/id_rsa && ssh-add /tmp/id_rsa && sbt -Dakka.genjavadoc.enabled=true publishRsync
- name: Publish
run: |-
eval "$(ssh-agent -s)"
echo $AKKA_RSYNC_GUSTAV | base64 -d > .github/id_rsa
chmod 600 .github/id_rsa
ssh-add .github/id_rsa
sbt -Dakka.genjavadoc.enabled=true publishRsync
env:
SCP_SECRET: ${{ secrets.SCP_SECRET }}
AKKA_RSYNC_GUSTAV: ${{ secrets.AKKA_RSYNC_GUSTAV }}

- name: Email on failure
if: ${{ failure() }}
uses: dawidd6/action-send-mail@6063705cefe50cb915fc53bb06d4049cae2953b2
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: "Failed: ${{ github.workflow }} / ${{ github.job }}"
to: ${{secrets.MAIL_SEND_TO}}
from: Akka CI
body: |
Job ${{ github.job }} in workflow ${{ github.workflow }} of ${{github.repository}} failed!
https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A few more background information about the process can be found below.

### Release Automation with Github Action

Akka HTTP uses Github Actions and to release artifacts automatically to Akka's library repository. For commits to the `main` branch, it directly publishes artifacts to the Sonatype snapshot repository.
Akka HTTP uses Github Actions and to release artifacts automatically to Akka's library repository. For commits to the `main` branch, it publishes artifacts to the snapshot repository.

### Releasing only updated docs

Expand Down
20 changes: 10 additions & 10 deletions docs/src/main/paradox/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ For a more detailed description of our process, please refer to the [CONTRIBUTIN

Testing snapshot versions can help us find bugs before a release. We publish snapshot versions for every commit to the `main` branch.

The latest published snapshot version is [![SonatypeSnapshots-badge][]][SonatypeSnapshots].
Snapshot builds are available at https://repo.akka.io/snapshots. All Akka modules that belong to the same build have the same version.

### Configure repository

sbt
: ```scala
resolvers += "akka-http-snapshot-repository" at "https://oss.sonatype.org/content/repositories/snapshots"
resolvers += "Akka library snapshot repository".at("https://repo.akka.io/snapshots")
```

Maven
: ```xml
<project>
...
<repositories>
<repository>
<id>akka-http-snapshots</id>
<name>Akka HTTP Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repositories>
<repository>
<id>akka-repository</id>
<name>Akka library snapshot repository</name>
<url>https://repo.akka.io/snapshots</url>
</repository>
</repositories>
</repositories>
...
</project>
Expand All @@ -38,10 +40,8 @@ Gradle
: ```gradle
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
url "https://repo.akka.io/snapshots"
}
}
```

[SonatypeSnapshots-badge]: https://img.shields.io/nexus/s/https/oss.sonatype.org/com.typesafe.akka/akka-http-core_2.13.svg
[SonatypeSnapshots]: https://oss.sonatype.org/content/repositories/snapshots/com/typesafe/akka/akka-http-core_2.13/
35 changes: 10 additions & 25 deletions project/AkkaDependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ object AkkaDependency {
case None =>
Option(System.getProperty("akka.http.build.akka.version")) match {
case Some("main") | Some("master") => mainSnapshot
case Some("release-2.6") =>
// Don't 'downgrade' building even if akka.sources asks for it
// (typically for the docs that require 2.6)
if (defaultVersion.startsWith("2.6")) Artifact(determineLatestSnapshot("2.6"), true)
else Artifact(defaultVersion)
case Some("snapshot") => Artifact(determineLatestSnapshot(), true)
case Some("default") => Artifact(defaultVersion)
case Some(other) => Artifact(other, true)
case None => Artifact(defaultVersion)
Expand Down Expand Up @@ -80,34 +76,23 @@ object AkkaDependency {
"com.typesafe.akka" %% module % akkaVersion % config
},
resolvers += "Akka library repository".at("https://repo.akka.io/maven"),
resolvers ++= (if (akkaSnapshot) Seq("Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") else Nil)
resolvers ++= (if (akkaSnapshot) Seq("Akka library snapshot repository".at("https://repo.akka.io/snapshots")) else Nil)
)
}
}

private def determineLatestSnapshot(prefix: String = ""): String = {
private def determineLatestSnapshot(): String = {
import sbt.librarymanagement.Http.http
import gigahorse.GigahorseSupport.url
import scala.concurrent.Await
import scala.concurrent.duration._

val snapshotVersionR = """href=".*/((\d+)\.(\d+)\.(\d+)\+(\d+)-[0-9a-f]+-SNAPSHOT)/"""".r

// akka-cluster-sharding-typed_2.13 seems to be the last nightly published by `akka-publish-nightly` so if that's there then it's likely the rest also made it
val body = Await.result(http.run(url("https://oss.sonatype.org/content/repositories/snapshots/com/typesafe/akka/akka-cluster-sharding-typed_2.13/")), 10.seconds).bodyAsString
val allVersions =
snapshotVersionR.findAllMatchIn(body)
.map {
case Groups(full, ep, maj, min, offset) =>
(
ep.toInt,
maj.toInt,
min.toInt,
offset.toInt
) -> full
}
.filter(_._2.startsWith(prefix))
.toVector.sortBy(_._1)
allVersions.last._2
val versionFile = "https://doc.akka.io/docs/akka/snapshot/paradox.json"
val body = Await.result(http.run(url(versionFile)), 10.seconds).bodyAsString
val versionProperty = """"version" : """"
val i = body.indexOf(versionProperty)
if (i == -1)
throw new RuntimeException(s"No version in $versionFile")
body.substring(i).split('"')(3)
}
}
11 changes: 6 additions & 5 deletions project/Publish.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ object Publish extends AutoPlugin {
sonatypeProfileName := "com.typesafe",
beforePublishTask := beforePublish(isSnapshot.value),
publishSigned := publishSigned.dependsOn(beforePublishTask).value,
publishTo := (if (isSnapshot.value)
Some(Resolver.file("file", target.value / "repository")) // FIXME snapshot repo
else
Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka/"))),
credentials ++= (if (isSnapshot.value) Seq[Credentials]() else cloudsmithCredentials(validate = false))
publishTo :=
(if (isSnapshot.value)
Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka-snapshots/"))
else
Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka/"))),
credentials ++= cloudsmithCredentials(validate = false)
)

def cloudsmithCredentials(validate: Boolean): Seq[Credentials] = {
Expand Down

0 comments on commit f429383

Please sign in to comment.