Skip to content

Commit

Permalink
fix sonatype publishing and github release creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jan 21, 2025
1 parent 82176fa commit 96671bd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/publish-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,28 @@ jobs:
include:
- os: ubuntu-latest
coursierarchive: ""
publishartifacts: ""
publishartifacts: __.publishArtifacts
uploadgithub: true

- os: ubuntu-24.04-arm
coursierarchive: ""
publishartifacts: dist.native.publishArtifacts
uploadgithub: false

- os: macos-13
coursierarchive: ""
publishartifacts: dist.native.publishArtifacts
uploadgithub: false

- os: macos-latest
coursierarchive: ""
publishartifacts: dist.native.publishArtifacts
uploadgithub: false

- os: windows-latest
coursierarchive: C:/coursier-arc
publishartifacts: dist.native.publishArtifacts
uploadgithub: false

# No windows-arm support becaues Graal native image doesn't support it
# https://github.com/oracle/graal/issues/9215
Expand All @@ -58,6 +63,7 @@ jobs:
LC_MESSAGES: "en_US.UTF-8"
LC_ALL: "en_US.UTF-8"
COURSIER_ARCHIVE_CACHE: ${{ matrix.coursierarchive }}
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
steps:
- uses: actions/setup-java@v4
with:
Expand All @@ -69,4 +75,7 @@ jobs:

- run: "echo temurin:11 > .mill-jvm-version"

- run: ./mill -i mill.scalalib.PublishModule/ --publishArtifacts dist.native.publishArtifacts
- run: ./mill -i mill.scalalib.PublishModule/ --publishArtifacts ${{ matrix.publishartifacts }}

- run: ./mill -i dist.uploadToGithub --authKey $REPO_ACCESS_TOKEN
if: ${{ matrix.uploadgithub }}
21 changes: 21 additions & 0 deletions dist/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,27 @@ object `package` extends RootModule with InstallModule {
)
}

def uploadToGithub(authKey: String) = Task.Command {
val vcsState = VcsVersion.vcsState()
val label = vcsState.copy(dirtyHash = None).format()
if (label != build.millVersion()) sys.error("Modified mill version detected, aborting upload")
val releaseTag = vcsState.lastTag.getOrElse(sys.error(
"Incomplete git history. No tag found.\nIf on CI, make sure your git checkout job includes enough history."
))

// Only create releases for tag pushes, not for unstable commit releases
if (releaseTag == label) {
// TODO: check if the tag already exists (e.g. because we created it manually) and do not fail
requests.post(
s"https://api.github.com/repos/${build.Settings.githubOrg}/${build.Settings.githubRepo}/releases",
data = ujson.Obj("tag_name" -> releaseTag, "name" -> releaseTag, "prerelease" -> true),
headers = Seq("Authorization" -> ("token " + authKey))
)
}

()
}

object native extends mill.scalalib.NativeImageModule with InstallModule {
def artifactOsSuffix = T {
val osName = System.getProperty("os.name").toLowerCase
Expand Down

0 comments on commit 96671bd

Please sign in to comment.