Skip to content

Commit

Permalink
Automate choco package deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
wleczny committed Oct 7, 2022
1 parent b2f7ee1 commit 9633e45
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,25 @@ jobs:
SDKMAN_KEY: ${{ secrets.SDKMAN_KEY }}
SDKMAN_TOKEN: ${{ secrets.SDKMAN_TOKEN }}
- run: ./mill -i ci.updateScalaCliSetup

update-windows-packages:
name: Update Windows packages
needs: launchers
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'VirtusLab/scala-cli'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- uses: VirtusLab/scala-cli-setup@4ee345865ae875b65ecbf9b97a481700d3cf5429
with:
jvm: "temurin:17"
- uses: actions/download-artifact@v3
with:
name: windows-launchers
path: artifacts/
- name: Publish to chocolatey
run: ./mill -i ci.updateChocolateyPackage
env:
CHOCO_SECRET: ${{ secrets.CHOCO_SECRET_KEY }}
44 changes: 44 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,50 @@ object ci extends Module {

commitChanges(s"Update Debian packages for $version", branch, packagesDir)
}
def updateChocolateyPackage() = T.command {
val version = cli.publishVersion()

val packagesDir = os.pwd / "target" / "scala-cli-packages"
val chocoDir = os.pwd / ".github" / "scripts" / "choco"

val msiPackagePath = packagesDir / s"scala-cli_$version.msi"
os.copy(
os.pwd / "artifacts" / "scala-cli-x86_64-pc-win32.msi",
msiPackagePath,
createFolders = true
)

// prepare ps1 file
val ps1Path = chocoDir / "tools" / "chocolateyinstall.ps1"

val launcherURL =
s"https://github.com/VirtusLab/scala-cli/releases/download/v$version/scala-cli-x86_64-pc-win32.msi"
val bytes = os.read.stream(msiPackagePath)
val sha256 = os.proc("sha256sum").call(cwd = packagesDir, stdin = bytes).out.trim.take(64)
val ps1UpdatedContent = os.read(ps1Path)
.replace("@LAUNCHER_URL@", launcherURL)
.replace("@LAUNCHER_SHA256@", sha256.toUpperCase)

os.write.over(ps1Path, ps1UpdatedContent)

// prepare nuspec file
val nuspecPath = chocoDir / "scala-cli.nuspec"
val nuspecUpdatedContent = os.read(nuspecPath).replace("@LAUNCHER_VERSION@", version)
os.write.over(nuspecPath, nuspecUpdatedContent)

os.proc("choco", "pack", nuspecPath, "--out", chocoDir).call(cwd = chocoDir)
val chocoKey =
Option(System.getenv("CHOCO_SECRET")).getOrElse(sys.error("CHOCO_SECRET not set"))
os.proc(
"choco",
"push",
chocoDir / s"scala-cli.$version.nupkg",
"-s",
"https://push.chocolatey.org/",
"-k",
chocoKey
).call(cwd = chocoDir)
}
def updateCentOsPackages() = T.command {
val version = cli.publishVersion()

Expand Down

0 comments on commit 9633e45

Please sign in to comment.