Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Publish Dated SNAPSHOTs #2591

Draft
wants to merge 3 commits into
base: master-deprecated
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
publish:
needs: [all_tests_passed]
runs-on: ubuntu-latest
if: github.event_name == 'push'
if: github.event_name == 'push'

steps:
- name: Checkout
Expand All @@ -126,7 +126,9 @@ jobs:
- name: Setup GPG (for Publish)
uses: olafurpg/setup-gpg@v3
- name: Publish
run: sbt ci-release
run: |
sbt ci-release
sbt -Ddatedsnapshot ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
Expand Down
13 changes: 12 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,20 @@ lazy val isAtLeastScala213 = Def.setting {
CrossVersion.partialVersion(scalaVersion.value).exists(_ >= (2, 13))
}

def currentVersion(major: String): String = {
val doDatedSnapshot = sys.props.get("datedsnapshot")
if (doDatedSnapshot.isDefined) {
val basicFormat = java.time.format.DateTimeFormatter.BASIC_ISO_DATE
val date = java.time.LocalDate.now().format(basicFormat)
s"$major-$date-SNAPSHOT"
Comment on lines +18 to +21
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a lot better if the date were derived from the commit hash so that we don't have old commits pushing over today's date. I also think the BuildInfo should include the commit hash so that users can check this info.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use git describe --tag or some variation of this to get <latest-tag>-<new-commits>-g<git-hash> instead of the date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we include the commit hash, it will publish a SNAPSHOT for every commit whereas I was trying to just have 1 per day. To keep the number of snapshots down we could instead put it on a "nightly" trigger, but that makes downstream projects more annoying to do because you want to make sure they publish their nightly SNAPSHOT after and upstream dependencies do. Just sticking with a dated one makes that a little bit simpler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every commit can be useful as you are known to be pinned to something obvious. Nightly is annoying because it's a question of when (have to check the cron job to see when nightly is defined). FWIW: here are the commit hash snapshots for sifive/chisel-circt: https://oss.sonatype.org/content/repositories/snapshots/com/sifive/chisel-circt_2.13/ This has been useful in the past.

} else {
s"$major-SNAPSHOT"
}
}

lazy val firrtlSettings = Seq(
name := "firrtl",
version := "1.6-SNAPSHOT",
version := currentVersion("1.6"),
addCompilerPlugin(scalafixSemanticdb),
scalacOptions := Seq(
"-deprecation",
Expand Down