From d0091b799f822281b36f7eaacfa2572c29188e6b Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Sat, 8 Jun 2024 14:05:50 +0100 Subject: [PATCH 1/4] Add Chocolatey package code --- pkgs/README.md | 15 +++++++ pkgs/chocolatey/README.md | 10 +++++ pkgs/chocolatey/icon.svg | 30 +++++++++++++ pkgs/chocolatey/scala.nuspec | 25 +++++++++++ pkgs/chocolatey/tools/chocolateyInstall.ps1 | 44 +++++++++++++++++++ pkgs/chocolatey/tools/chocolateyUninstall.ps1 | 21 +++++++++ 6 files changed, 145 insertions(+) create mode 100644 pkgs/README.md create mode 100644 pkgs/chocolatey/README.md create mode 100644 pkgs/chocolatey/icon.svg create mode 100644 pkgs/chocolatey/scala.nuspec create mode 100644 pkgs/chocolatey/tools/chocolateyInstall.ps1 create mode 100644 pkgs/chocolatey/tools/chocolateyUninstall.ps1 diff --git a/pkgs/README.md b/pkgs/README.md new file mode 100644 index 000000000000..86b0dc6b6fe6 --- /dev/null +++ b/pkgs/README.md @@ -0,0 +1,15 @@ +

Configuration for Chocolatey

+ +Official support for Chocolatey started by the release of Scala 3.6.0 + +> [!IMPORTANT] +> This folder contains the templates to generate the configuration for Chocolatey. +> The `scala.nuspec` and `chocolateyInstall.ps1` files needs to be rewritten by changing the following placeholders: +> - @LAUNCHER_VERSION@ : Placeholder for the current scala version to deploy +> - @LAUNCHER_URL@ : Placeholder for the URL to the windows zip released on GitHub + +## Important information + +- How to create a *Chocolatey* package: https://docs.chocolatey.org/en-us/create/create-packages/ +- Guidelines to follow for the package icon: https://docs.chocolatey.org/en-us/create/create-packages/#package-icon-guidelines +- `.nuspec` format specification: https://learn.microsoft.com/en-gb/nuget/reference/nuspec diff --git a/pkgs/chocolatey/README.md b/pkgs/chocolatey/README.md new file mode 100644 index 000000000000..fac301082bac --- /dev/null +++ b/pkgs/chocolatey/README.md @@ -0,0 +1,10 @@ +

Configuration for Chocolatey

+ +Official support for Chocolatey started by the release of Scala 3.6.0 + +> [!IMPORTANT] +> This folder contains the templates to generate the configuration for Chocolatey. +> The `scala.nuspec` and `chocolateyInstall.ps1` files needs to be rewritten by changing the following placeholders: +> - @LAUNCHER_VERSION@ : Placeholder for the current scala version to deploy +> - @LAUNCHER_URL@ : Placeholder for the URL to the windows zip released on GitHub +> - @LAUNCHER_SHA256@ : Placeholder for the SHA256 of the msi file released on GitHub diff --git a/pkgs/chocolatey/icon.svg b/pkgs/chocolatey/icon.svg new file mode 100644 index 000000000000..0ccb404b5624 --- /dev/null +++ b/pkgs/chocolatey/icon.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pkgs/chocolatey/scala.nuspec b/pkgs/chocolatey/scala.nuspec new file mode 100644 index 000000000000..2fff36a83d5b --- /dev/null +++ b/pkgs/chocolatey/scala.nuspec @@ -0,0 +1,25 @@ + + + + scala + @LAUNCHER_VERSION@ + Scala + scala + scala + scala + Scala + Official release of the Scala Programming Language on Chocolatey. + https://github.com/scala/scala3/tree/main/pkgs/chocolatey + https://github.com/scala/scala3 + https://scala-lang.org/ + https://github.com/scala/scala3/issues + © 2002-2024, LAMP/EPFL + https://cdn.jsdelivr.net/gh/scala/scala3@version/pkgs/chocolatey/icon.svg + https://github.com/scala/scala3/blob/main/LICENSE + true + https://github.com/scala/scala3/releases + + + + + diff --git a/pkgs/chocolatey/tools/chocolateyInstall.ps1 b/pkgs/chocolatey/tools/chocolateyInstall.ps1 new file mode 100644 index 000000000000..dc8874942561 --- /dev/null +++ b/pkgs/chocolatey/tools/chocolateyInstall.ps1 @@ -0,0 +1,44 @@ +$ErrorActionPreference = 'Stop'; + +$unzipLocation = Split-Path -Parent $MyInvocation.MyCommand.Definition # Get the root of chocolatey folder +$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageName)" # Append the package's name +$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # Append the package's version + +# Configure the installation arguments +$packageArgs = @{ + packageName = 'scala' + Url64 = '@LAUNCHER_URL@' + UnzipLocation = $unzipLocation +} + +## In case we are running in the CI, add the authorisation header to fetch the zip +## See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#download-an-artifact +if ($env:DOTTY_CI_INSTALLATION) { + Write-Host "Installing the Chocolatey package in Scala 3's CI" + $packageArgs += @{ + Options = @{ + Headers = @{ + Accept = 'application/vnd.github+json' + Authorization = "Bearer $env:DOTTY_CI_INSTALLATION" + } + } + } +} + +Install-ChocolateyZipPackage @packageArgs + +# Find the path to the bin directory to create the shims +if($env:DOTTY_CI_INSTALLATION) { + $scalaBinPath = Join-Path $unzipLocation 'bin' # Update this path if the structure inside the ZIP changes +} else { + $extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin' +} + +# Iterate through the .bat files in the bin directory and create shims +Write-Host "Creating shims for .bat file from $scalaBinPath" +Get-ChildItem -Path $scalaBinPath -Filter '*.bat' | ForEach-Object { + $file = $_.FullName + Write-Host "Creating shim for $file..." + Install-BinFile -Name $_.BaseName -Path $file +} diff --git a/pkgs/chocolatey/tools/chocolateyUninstall.ps1 b/pkgs/chocolatey/tools/chocolateyUninstall.ps1 new file mode 100644 index 000000000000..387914af5d09 --- /dev/null +++ b/pkgs/chocolatey/tools/chocolateyUninstall.ps1 @@ -0,0 +1,21 @@ +$ErrorActionPreference = 'Stop'; + +$unzipLocation = Split-Path -Parent $MyInvocation.MyCommand.Definition # Get the root of chocolatey folder +$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageName)" # Append the package's name +$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # Append the package's version + +# Find the path to the bin directory to create the shims +if($env:DOTTY_CI_INSTALLATION) { + $scalaBinPath = Join-Path $unzipLocation 'bin' # Update this path if the structure inside the ZIP changes + } else { + $extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + $scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin' + } + +# Iterate through the .bat files in the bin directory and remove shims +Write-Host "Removing shims for .bat file from $scalaBinPath" +Get-ChildItem -Path $scalaBinPath -Filter '*.bat' | ForEach-Object { + $file = $_.FullName + Write-Host "Removing shim for $file..." + Uninstall-BinFile -Name $_.BaseName -Path $file +} From b67e1861935752a228710b7f69b98651438c60b2 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Wed, 17 Jul 2024 14:35:20 +0200 Subject: [PATCH 2/4] Add workflow for Chocolatey --- .github/workflows/build-chocolatey.yml | 48 ++++++++++ .github/workflows/build-sdk.yml | 106 +++++++++++++++++++++++ .github/workflows/ci.yaml | 20 +++++ .github/workflows/publish-chocolatey.yml | 39 +++++++++ .github/workflows/releases.yml | 19 ++++ .github/workflows/test-chocolatey.yml | 51 +++++++++++ 6 files changed, 283 insertions(+) create mode 100644 .github/workflows/build-chocolatey.yml create mode 100644 .github/workflows/build-sdk.yml create mode 100644 .github/workflows/publish-chocolatey.yml create mode 100644 .github/workflows/test-chocolatey.yml diff --git a/.github/workflows/build-chocolatey.yml b/.github/workflows/build-chocolatey.yml new file mode 100644 index 000000000000..d1326c19ed87 --- /dev/null +++ b/.github/workflows/build-chocolatey.yml @@ -0,0 +1,48 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO BUILD SCALA WITH CHOCOLATEY ### +### HOW TO USE: ### +### ### +### NOTE: ### +### ### +################################################################################################### + + +name: Build 'scala' Chocolatey Package +run-name: Build 'scala' (${{ inputs.version }}) Chocolatey Package + +on: + workflow_call: + inputs: + version: + required: true + type: string + url: + required: true + type: string + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Replace the version placeholder + uses: richardrigutins/replace-in-files@v2 + with: + files: ./pkgs/chocolatey/scala.nuspec + search-text: '@LAUNCHER_VERSION@' + replacement-text: ${{ inputs.version }} + - name: Replace the URL placeholder + uses: richardrigutins/replace-in-files@v2 + with: + files: ./pkgs/chocolatey/tools/chocolateyInstall.ps1 + search-text: '@LAUNCHER_URL@' + replacement-text: ${{ inputs.url }} + - name: Build the Chocolatey package (.nupkg) + run: choco pack ./pkgs/chocolatey/scala.nuspec --out ./pkgs/chocolatey + - name: Upload the Chocolatey package to GitHub + uses: actions/upload-artifact@v4 + with: + name: scala.nupkg + path: ./pkgs/chocolatey/scala.${{ inputs.version }}.nupkg + if-no-files-found: error + \ No newline at end of file diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml new file mode 100644 index 000000000000..935e19c7d90c --- /dev/null +++ b/.github/workflows/build-sdk.yml @@ -0,0 +1,106 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO BUILD THE SCALA LAUNCHERS ### +### HOW TO USE: ### +### - THSI WORKFLOW WILL PACKAGE THE ALL THE LAUNCHERS AND UPLOAD THEM TO GITHUB ARTIFACTS ### +### ### +### NOTE: ### +### - SEE THE WORFLOW FOR THE NAMES OF THE ARTIFACTS ### +################################################################################################### + + +name: Build Scala Launchers +run-name: Build Scala Launchers + +on: + workflow_call: + inputs: + java-version: + type : string + required : true + outputs: + universal-id: + description: ID of the `universal` package from GitHub Artifacts (Authentication Required) + value : ${{ jobs.build.outputs.universal-id }} + linux-x86_64-id: + description: ID of the `linux x86-64` package from GitHub Artifacts (Authentication Required) + value : ${{ jobs.build.outputs.linux-x86_64-id }} + linux-aarch64-id: + description: ID of the `linux aarch64` package from GitHub Artifacts (Authentication Required) + value : ${{ jobs.build.outputs.linux-aarch64-id }} + mac-x86_64-id: + description: ID of the `mac x86-64` package from GitHub Artifacts (Authentication Required) + value : ${{ jobs.build.outputs.mac-x86_64-id }} + mac-aarch64-id: + description: ID of the `mac aarch64` package from GitHub Artifacts (Authentication Required) + value : ${{ jobs.build.outputs.mac-aarch64-id }} + win-x86_64-id: + description: ID of the `win x86-64` package from GitHub Artifacts (Authentication Required) + value : ${{ jobs.build.outputs.win-x86_64-id }} + + +jobs: + build: + runs-on: ubuntu-latest + outputs: + universal-id : ${{ steps.universal.outputs.artifact-id }} + linux-x86_64-id : ${{ steps.linux-x86_64.outputs.artifact-id }} + linux-aarch64-id: ${{ steps.linux-aarch64.outputs.artifact-id }} + mac-x86_64-id : ${{ steps.mac-x86_64.outputs.artifact-id }} + mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }} + win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + cache : sbt + - name: Build and pack the SDK (universal) + run : ./project/scripts/sbt dist/Universal/stage + - name: Build and pack the SDK (linux x86-64) + run : ./project/scripts/sbt dist-linux-x86_64/Universal/stage + - name: Build and pack the SDK (linux aarch64) + run : ./project/scripts/sbt dist-linux-aarch64/Universal/stage + - name: Build and pack the SDK (mac x86-64) + run : ./project/scripts/sbt dist-mac-x86_64/Universal/stage + - name: Build and pack the SDK (mac aarch64) + run : ./project/scripts/sbt dist-mac-aarch64/Universal/stage + - name: Build and pack the SDK (win x86-64) + run : ./project/scripts/sbt dist-win-x86_64/Universal/stage + - name: Upload zip archive to GitHub Artifact (universal) + uses: actions/upload-artifact@v4 + id : universal + with: + path: ./dist/target/universal/stage + name: scala3-universal + - name: Upload zip archive to GitHub Artifact (linux x86-64) + uses: actions/upload-artifact@v4 + id : linux-x86_64 + with: + path: ./dist/linux-x86_64/target/universal/stage + name: scala3-x86_64-pc-linux + - name: Upload zip archive to GitHub Artifact (linux aarch64) + uses: actions/upload-artifact@v4 + id : linux-aarch64 + with: + path: ./dist/linux-aarch64/target/universal/stage + name: scala3-aarch64-pc-linux + - name: Upload zip archive to GitHub Artifact (mac x86-64) + uses: actions/upload-artifact@v4 + id : mac-x86_64 + with: + path: ./dist/mac-x86_64/target/universal/stage + name: scala3-x86_64-apple-darwin + - name: Upload zip archive to GitHub Artifact (mac aarch64) + uses: actions/upload-artifact@v4 + id : mac-aarch64 + with: + path: ./dist/mac-aarch64/target/universal/stage + name: scala3-aarch64-apple-darwin + - name: Upload zip archive to GitHub Artifact (win x86-64) + uses: actions/upload-artifact@v4 + id : win-x86_64 + with: + path: ./dist/win-x86_64/target/universal/stage + name: scala3-x86_64-pc-win32 + \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74c4741c1ab4..8b98448a98bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1013,3 +1013,23 @@ jobs: uses: ./.github/workflows/build-msi.yml if : github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]') # TODO: ADD A JOB THAT DEPENDS ON THIS TO TEST THE MSI + + build-sdk-package: + uses: ./.github/workflows/build-sdk.yml + with: + java-version: 8 + + build-chocolatey-package: + uses: ./.github/workflows/build-chocolatey.yml + needs: [ build-sdk-package ] + with: + version: 3.6.0-local # TODO: FIX THIS + url : https://api.github.com/repos/scala/scala3/actions/artifacts/${{ needs.build-sdk-package.outputs.win-x86_64-id }}/zip + + test-chocolatey-package: + uses: ./.github/workflows/test-chocolatey.yml + with: + version : 3.6.0-local # TODO: FIX THIS + java-version: 8 + if: github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_chocolatey]') + needs: [ build-chocolatey-package ] diff --git a/.github/workflows/publish-chocolatey.yml b/.github/workflows/publish-chocolatey.yml new file mode 100644 index 000000000000..3b31728a50ba --- /dev/null +++ b/.github/workflows/publish-chocolatey.yml @@ -0,0 +1,39 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO PUBLISH SCALA TO CHOCOLATEY ### +### HOW TO USE: ### +### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ### +### - IT WILL PUBLISH TO CHOCOLATEY THE MSI ### +### ### +### NOTE: ### +### - WE SHOULD KEEP IN SYNC THE NAME OF THE MSI WITH THE ACTUAL BUILD ### +### - WE SHOULD KEEP IN SYNC THE URL OF THE RELEASE ### +### - IT ASSUMES THAT THE `build-chocolatey` WORKFLOW WAS EXECUTED BEFORE ### +################################################################################################### + + +name: Publish Scala to Chocolatey +run-name: Publish Scala ${{ inputs.version }} to Chocolatey + +on: + workflow_call: + inputs: + version: + required: true + type: string + secrets: + # Connect to https://community.chocolatey.org/profiles/scala + # Accessible via https://community.chocolatey.org/account + API-KEY: + required: true + +jobs: + publish: + runs-on: windows-latest + steps: + - name: Fetch the Chocolatey package from GitHub + uses: actions/download-artifact@v4 + with: + name: scala.nupkg + - name: Publish the package to Chocolatey + run: choco push scala.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.API-KEY }} + \ No newline at end of file diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index a4977bc5ffd9..f0edbac4127a 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -37,4 +37,23 @@ jobs: secrets: DOTTYBOT-TOKEN: ${{ secrets.DOTTYBOT_WINGET_TOKEN }} + build-chocolatey: + uses: ./.github/workflows/build-chocolatey.yml + with: + version: ${{ inputs.version }} + url : 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip' + test-chocolatey: + uses: ./.github/workflows/test-chocolatey.yml + needs: build-chocolatey + with: + version : ${{ inputs.version }} + java-version: 8 + publish-chocolatey: + uses: ./.github/workflows/publish-chocolatey.yml + needs: [ build-chocolatey, test-chocolatey ] + with: + version: ${{ inputs.version }} + secrets: + API-KEY: ${{ secrets.CHOCOLATEY_KEY }} + # TODO: ADD RELEASE WORKFLOW TO CHOCOLATEY AND OTHER PACKAGE MANAGERS HERE \ No newline at end of file diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml new file mode 100644 index 000000000000..b6ca9bf74b12 --- /dev/null +++ b/.github/workflows/test-chocolatey.yml @@ -0,0 +1,51 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH CHOCOLATEY ### +### HOW TO USE: ### +### ### +### NOTE: ### +### ### +################################################################################################### + +name: Test 'scala' Chocolatey Package +run-name: Test 'scala' (${{ inputs.version }}) Chocolatey Package + +on: + workflow_call: + inputs: + version: + required: true + type: string + java-version: + required: true + type : string + +env: + CHOCOLATEY-REPOSITORY: chocolatey-pkgs + DOTTY_CI_INSTALLATION: ${{ secrets.GITHUB_TOKEN }} + +jobs: + test: + runs-on: windows-latest + steps: + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + - name: Download the 'nupkg' from GitHub Artifacts + uses: actions/download-artifact@v4 + with: + name: scala.nupkg + path: ${{ env.CHOCOLATEY-REPOSITORY }} + - name : Install the `scala` package with Chocolatey + run : choco install scala --source "${{ env.CHOCOLATEY-REPOSITORY }}" --pre # --pre since we might be testing non-stable releases + shell: pwsh + - name : Test the `scala` command + run : scala --version + shell: pwsh + - name : Test the `scalac` command + run : scalac --version + - name : Test the `scaladoc` command + run : scaladoc --version + - name : Uninstall the `scala` package + run : choco uninstall scala + \ No newline at end of file From 5af4908c86f92d328c4cc98a7fbba3050528e4d8 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Wed, 17 Jul 2024 17:35:54 +0200 Subject: [PATCH 3/4] Add support for checksums in Chocolatey --- .github/workflows/build-chocolatey.yml | 13 ++++++++++-- .github/workflows/build-sdk.yml | 22 +++++++++++++++------ .github/workflows/ci.yaml | 1 + .github/workflows/releases.yml | 13 ++++++++++++ pkgs/chocolatey/tools/chocolateyInstall.ps1 | 8 +++++--- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-chocolatey.yml b/.github/workflows/build-chocolatey.yml index d1326c19ed87..9de87d8e5ad6 100644 --- a/.github/workflows/build-chocolatey.yml +++ b/.github/workflows/build-chocolatey.yml @@ -15,10 +15,13 @@ on: inputs: version: required: true - type: string + type : string url: required: true - type: string + type : string + digest: + required: true + type : string jobs: build: @@ -37,6 +40,12 @@ jobs: files: ./pkgs/chocolatey/tools/chocolateyInstall.ps1 search-text: '@LAUNCHER_URL@' replacement-text: ${{ inputs.url }} + - name: Replace the CHECKSUM placeholder + uses: richardrigutins/replace-in-files@v2 + with: + files: ./pkgs/chocolatey/tools/chocolateyInstall.ps1 + search-text: '@LAUNCHER_SHA256@' + replacement-text: ${{ inputs.digest }} - name: Build the Chocolatey package (.nupkg) run: choco pack ./pkgs/chocolatey/scala.nuspec --out ./pkgs/chocolatey - name: Upload the Chocolatey package to GitHub diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml index 935e19c7d90c..0233403894fb 100644 --- a/.github/workflows/build-sdk.yml +++ b/.github/workflows/build-sdk.yml @@ -36,18 +36,22 @@ on: win-x86_64-id: description: ID of the `win x86-64` package from GitHub Artifacts (Authentication Required) value : ${{ jobs.build.outputs.win-x86_64-id }} + win-x86_64-digest: + description: The SHA256 of the uploaded artifact (`win x86-64`) + value : ${{ jobs.build.outputs.win-x86_64-digest }} jobs: build: runs-on: ubuntu-latest outputs: - universal-id : ${{ steps.universal.outputs.artifact-id }} - linux-x86_64-id : ${{ steps.linux-x86_64.outputs.artifact-id }} - linux-aarch64-id: ${{ steps.linux-aarch64.outputs.artifact-id }} - mac-x86_64-id : ${{ steps.mac-x86_64.outputs.artifact-id }} - mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }} - win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }} + universal-id : ${{ steps.universal.outputs.artifact-id }} + linux-x86_64-id : ${{ steps.linux-x86_64.outputs.artifact-id }} + linux-aarch64-id : ${{ steps.linux-aarch64.outputs.artifact-id }} + mac-x86_64-id : ${{ steps.mac-x86_64.outputs.artifact-id }} + mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }} + win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }} + win-x86_64-digest: ${{ steps.win-x86_64-digest.outputs.digest }} steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 @@ -103,4 +107,10 @@ jobs: with: path: ./dist/win-x86_64/target/universal/stage name: scala3-x86_64-pc-win32 + - name: Compute SHA256 of the uploaded artifact (win x86-64) + id : win-x86_64-digest + run : | + curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o artifact.zip -L https://api.github.com/repos/scala/scala3/actions/artifacts/${{ steps.win-x86_64.outputs.artifact-id }}/zip + echo "digest=$(sha256sum artifact.zip | cut -d " " -f 1)" >> "$GITHUB_OUTPUT" + \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b98448a98bd..d4583847c438 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1025,6 +1025,7 @@ jobs: with: version: 3.6.0-local # TODO: FIX THIS url : https://api.github.com/repos/scala/scala3/actions/artifacts/${{ needs.build-sdk-package.outputs.win-x86_64-id }}/zip + digest : ${{ needs.build-sdk-package.outputs.win-x86_64-digest }} test-chocolatey-package: uses: ./.github/workflows/test-chocolatey.yml diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index f0edbac4127a..ab921ec588d2 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -37,11 +37,24 @@ jobs: secrets: DOTTYBOT-TOKEN: ${{ secrets.DOTTYBOT_WINGET_TOKEN }} + compute-digest: + runs-on: ubuntu-latest + outputs: + digest: ${{ steps.digest.outputs.digest }} + steps: + - name: Compute the SHA256 of scala3-${{ inputs.version }}-x86_64-pc-win32.zip in GitHub Release + id: digest + run: | + curl -o artifact.zip -L https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip + echo "digest=$(sha256sum artifact.zip | cut -d " " -f 1)" >> "$GITHUB_OUTPUT" + build-chocolatey: uses: ./.github/workflows/build-chocolatey.yml + needs: compute-digest with: version: ${{ inputs.version }} url : 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip' + digest : ${{ needs.compute-digest.outputs.digest }} test-chocolatey: uses: ./.github/workflows/test-chocolatey.yml needs: build-chocolatey diff --git a/pkgs/chocolatey/tools/chocolateyInstall.ps1 b/pkgs/chocolatey/tools/chocolateyInstall.ps1 index dc8874942561..3117efadaf0e 100644 --- a/pkgs/chocolatey/tools/chocolateyInstall.ps1 +++ b/pkgs/chocolatey/tools/chocolateyInstall.ps1 @@ -6,9 +6,11 @@ $unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # # Configure the installation arguments $packageArgs = @{ - packageName = 'scala' - Url64 = '@LAUNCHER_URL@' - UnzipLocation = $unzipLocation + packageName = 'scala' + Url64 = '@LAUNCHER_URL@' + UnzipLocation = $unzipLocation + Checksum64 = '@LAUNCHER_SHA256@' + ChecksumType64 = 'SHA256' } ## In case we are running in the CI, add the authorisation header to fetch the zip From 442c0e942ce905d6d4696df1ce4ac3bc3afdb944 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Thu, 18 Jul 2024 14:04:37 +0200 Subject: [PATCH 4/4] Add `LAUNCHER_SHA256` description Co-authored-by: Jamie Thompson --- pkgs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/README.md b/pkgs/README.md index 86b0dc6b6fe6..9369fb822da1 100644 --- a/pkgs/README.md +++ b/pkgs/README.md @@ -7,6 +7,7 @@ Official support for Chocolatey started by the release of Scala 3.6.0 > The `scala.nuspec` and `chocolateyInstall.ps1` files needs to be rewritten by changing the following placeholders: > - @LAUNCHER_VERSION@ : Placeholder for the current scala version to deploy > - @LAUNCHER_URL@ : Placeholder for the URL to the windows zip released on GitHub +> - @LAUNCHER_SHA256@ : Placeholder for the SHA256 of the msi file released on GitHub ## Important information