Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop publishing artifacts to github releases since move to maven central #4386

Merged
merged 7 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 12 additions & 93 deletions .github/workflows/publish-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,91 +15,39 @@ on:
workflow_dispatch:

jobs:
build-artifacts:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill'
runs-on: ubuntu-latest
env:
MILL_STABLE_VERSION: 1
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}

- uses: coursier/cache-action@v6

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

- run: ./mill -i __.publishArtifacts

- uses: actions/upload-artifact@v4.6.0
with:
path: .
include-hidden-files: true
name: publish-artifacts

publish-sonatype:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill'
needs: build-artifacts
runs-on: ubuntu-latest

# only run one publish job for the same sha at the same time
# e.g. when a main-branch push is also tagged
concurrency: publish-sonatype-${{ github.sha }}

env:
MILL_STABLE_VERSION: 1
MILL_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MILL_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MILL_PGP_SECRET_BASE64: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY }}
MILL_PGP_PASSPHRASE: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY_PASSWORD }}
LANG: "en_US.UTF-8"
LC_MESSAGES: "en_US.UTF-8"
LC_ALL: "en_US.UTF-8"

steps:
- uses: actions/download-artifact@v4
with:
path: .
name: publish-artifacts

- run: ls -la .

# Need to fix cached artifact file permissions because github actions screws it up
# https://github.com/actions/upload-artifact/issues/38
# Best is, we restore any file to avoid any changes
- run: git reset --hard

- uses: coursier/cache-action@v6

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

- run: ./mill -i mill.scalalib.PublishModule/

publish-sonatype-native:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill'
runs-on: ${{ matrix.os }}

# only run one publish job for the same sha at the same time
# e.g. when a main-branch push is also tagged
concurrency: publish-sonatype-native-${{ matrix.os }}-${{ github.sha }}
concurrency: publish-sonatype-${{ matrix.os }}-${{ github.sha }}
strategy:
matrix:
include:
- os: ubuntu-latest
coursierarchive: ""
publishartifacts: ""

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

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

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

- os: windows-latest
coursierarchive: C:/coursier-arc
# Skip this because the main publishing job handles it
# - os: ubuntu-latest
publishartifacts: dist.native.publishArtifacts

# No windows-arm support becaues Graal native image doesn't support it
# https://github.com/oracle/graal/issues/9215
env:
MILL_STABLE_VERSION: 1
MILL_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
Expand All @@ -122,32 +70,3 @@ jobs:
- run: "echo temurin:11 > .mill-jvm-version"

- run: ./mill -i mill.scalalib.PublishModule/ --publishArtifacts dist.native.publishArtifacts

release-github:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill'
needs: publish-sonatype
runs-on: ubuntu-latest

env:
MILL_STABLE_VERSION: 1
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}

steps:
- uses: actions/download-artifact@v4
with:
path: .
name: publish-artifacts

- run: ls -la .

# Need to fix cached artifact file permissions because github actions screws it up
# https://github.com/actions/upload-artifact/issues/38
# Best is, we restore any file to avoid any changes
- run: git reset --hard

- uses: coursier/cache-action@v6

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

- run: ./mill -i dist.uploadToGithub --authKey $REPO_ACCESS_TOKEN
7 changes: 7 additions & 0 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ def millLastTag: T[String] = Task {
} else "SNAPSHOT"
}

def millDownloadPrefix = Task {
s"https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/"
}
def millDownloadUrl = Task {
s"https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/${millLastTag()}"
}

def millBinPlatform: T[String] = Task {
// val tag = millLastTag()
// if (tag.contains("-M")) tag
Expand Down
83 changes: 1 addition & 82 deletions dist/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ object `package` extends RootModule with InstallModule {
path = exampleMod.millSourcePath
} yield {
val example = path.subRelativeTo(Task.workspace)
val artifactName = build.millVersion() + "-" + example.segments.mkString("-")
val artifactName = example.segments.mkString("-")
(path, artifactName)
}
}
Expand All @@ -248,87 +248,6 @@ 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."
))

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))
)
}

val examples = exampleZips().map(z => (z.path, z.path.last))

val zips = examples ++ Seq(
(build.dist.assembly().path, label + "-assembly"),
(bootstrapLauncher().path, label),
(bootstrapLauncherBat().path, label + ".bat")
)

for ((zip, name) <- zips) {
upload(
zip,
releaseTag,
name,
authKey,
build.Settings.githubOrg,
build.Settings.githubRepo
)
}
}

def upload(
uploadedFile: os.Path,
tagName: String,
uploadName: String,
authKey: String,
githubOrg: String,
githubRepo: String
): String = {

val response = requests.get(
s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}",
headers = Seq(
"Authorization" -> s"token $authKey",
"Accept" -> "application/vnd.github.v3+json"
)
)

val parsed = ujson.read(response)

println("Response code: " + response.statusCode)
println(response.text())

val snapshotReleaseId = parsed("id").num.toInt

val uploadUrl =
s"https://uploads.github.com/repos/${githubOrg}/${githubRepo}/releases/" +
s"$snapshotReleaseId/assets?name=$uploadName"

val res = requests.post(
uploadUrl,
headers = Seq(
"Content-Type" -> "application/octet-stream",
"Authorization" -> s"token $authKey"
),
data = os.read.stream(uploadedFile)
)

println(res.text())
val longUrl = ujson.read(res)("browser_download_url").str

println("Long Url " + longUrl)
longUrl
}

def publishArtifacts = Task {
super.publishArtifacts()
.copy(payload =
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/cli/installation-ide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ you can also download it manually:
[source,bash,subs="verbatim,attributes"]
----
# Mac/Linux
curl -L {mill-download-url}/{mill-last-tag}/mill -o mill
curl -L {mill-download-url}/mill -o mill
chmod +x mill
echo {mill-last-tag} > .mill-version

# Windows
curl -L {mill-download-url}/{mill-last-tag}/mill.bat -o mill.bat
curl -L {mill-download-url}/mill.bat -o mill.bat
echo {mill-last-tag} > .mill-version
----

Expand Down
18 changes: 14 additions & 4 deletions docs/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ object `package` extends RootModule {
dest,
"main-branch",
"main-branch",
build.millLastTag()
build.millLastTag(),
build.millDownloadUrl()
)
PathRef(dest)
}
Expand All @@ -185,7 +186,8 @@ object `package` extends RootModule {
dest: os.Path,
version: String,
displayVersion: String,
millLastTag: String
millLastTag: String,
millDownloadUrl: String
): Unit = {
val isPreRelease = version == "main-branch" || Seq("-M", "-RC").exists(version.contains)
val preReleaseSuffix = if (isPreRelease) "\nprerelease: true" else ""
Expand All @@ -198,7 +200,7 @@ object `package` extends RootModule {
}

val newLines = Seq(
s" mill-download-url: https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/$millLastTag",
s" mill-download-url: $millDownloadUrl",
s" mill-example-url: ${build.Settings.projectUrl}/blob/$millLastTag/"
)

Expand Down Expand Up @@ -287,7 +289,15 @@ object `package` extends RootModule {
mill.main.VisualizeModule.classpath().map(_.path)
)

sanitizeAntoraYml(outputFolder, version, displayVersion, millLastTag)
val millDownloadUrl =
if (
Ordering.Implicits.seqOrdering[Seq, String].lt(version.split('.'), Seq("0", "12", "6"))
) {
s"${build.Settings.projectUrl}/releases/download/$millLastTag"
} else {
build.millDownloadUrl()
}
sanitizeAntoraYml(outputFolder, version, displayVersion, millLastTag, millDownloadUrl)
PathRef(outputFolder)
}
}
Expand Down
3 changes: 1 addition & 2 deletions example/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ object `package` extends RootModule with Module {
val title =
if (seenCode) ""
else {
val label = build.millLastTag()
val exampleDashed = examplePath.segments.mkString("-")
val download = s"{mill-download-url}/$label-$exampleDashed.zip[download]"
val download = s"{mill-download-url}/$exampleDashed.zip[download]"
val browse = s"{mill-example-url}/$examplePath[browse]"
s".build.mill ($download, $browse)"
}
Expand Down
Loading
Loading