From 3e95e832c474c3d138673caac803e94f7a6a4fc0 Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Wed, 31 Aug 2022 09:44:34 +0200 Subject: [PATCH 1/2] fix: don't use System.getenv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can find some more info about this in: https://com-lihaoyi.github.io/mill/mill/Task_Context_API.html#_mill_api_ctx_env Taken from there: > Mill keeps a long-lived JVM server to avoid paying the cost of recurrent classloading. Because of this, running System.getenv in a task might not yield up to date environment variables, since it will be initialised when the server starts, rather than when the client executes. To circumvent this, mill’s client sends the environment variables to the server as it sees them, and the server makes them available as a Map[String, String] via the Ctx API. --- .github/workflows/release.yml | 2 +- .../io/kipp/mill/ci/release/CiReleaseModule.scala | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d21e906..c0d5379 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: with: distribution: 'temurin' java-version: '17' - - run: ./mill -i -j 0 io.kipp.mill.ci.release.ReleaseModule/publishAll + - run: ./mill -i io.kipp.mill.ci.release.ReleaseModule/publishAll env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} diff --git a/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala b/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala index ae55f93..8c90e76 100644 --- a/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala +++ b/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala @@ -156,12 +156,12 @@ object ReleaseModule extends ExternalModule { * a Env Task */ private def setupEnv(): Task[Env] = T.input { - val pgpSecret = Option(System.getenv("PGP_SECRET")) - val pgpPassword = Option(System.getenv("PGP_PASSPHRASE")) - val isTag = - Option(System.getenv("GITHUB_REF")).exists(_.startsWith("refs/tags")) - val sonatypeUser = Option(System.getenv("SONATYPE_USERNAME")) - val sonatypePassword = Option(System.getenv("SONATYPE_PASSWORD")) + val env = T.ctx().env + val pgpSecret = env.get("PGP_SECRET") + val pgpPassword = env.get("PGP_PASSPHRASE") + val isTag = env.get("GITHUB_REF").exists(_.startsWith("refs/tags")) + val sonatypeUser = env.get("SONATYPE_USERNAME") + val sonatypePassword = env.get("SONATYPE_PASSWORD") if (pgpSecret.isEmpty) { Result.Failure("Missing PGP_SECRET. Make sure you have it set.") From cbd5b46be3796eea069446f44704a5152fd61443 Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Wed, 31 Aug 2022 09:48:15 +0200 Subject: [PATCH 2/2] docs: add another thing to the faq section --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 90ce407..e70b79f 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,17 @@ override def sonatypeSnapshotUri = "https://s01.oss.sonatype.org/content/repositories/snapshots" ``` +#### It's publishing a 0.0.0-something-SNAPSHOT even though I have a git tag + +If you see this it's probably because you forgot to add the `fetch-depth` in +checkout, meaning that no git tags are getting pulled in CI: + +```yaml +- uses: actions/checkout@v3 + with: + fetch-depth: 0 +``` + ## Notes This plugin has only really been tested on more minimal projects. There is