diff --git a/.github/workflows/build-chocolatey.yml b/.github/workflows/build-chocolatey.yml index 122b9bbe22bf..1088f6954465 100644 --- a/.github/workflows/build-chocolatey.yml +++ b/.github/workflows/build-chocolatey.yml @@ -38,7 +38,7 @@ jobs: search-text: '@LAUNCHER_URL@' replacement-text: ${{ inputs.url }} - name: Build the Chocolatey package (.nupkg) - run: choco --pack ./pkgs/chocolatey/scala.nuspec --outputdirectory ./pkgs/chocolatey + run: choco pack ./pkgs/chocolatey/scala.nuspec --out ./pkgs/chocolatey - name: Upload the Chocolatey package to GitHub uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml new file mode 100644 index 000000000000..100fb1b2d6d9 --- /dev/null +++ b/.github/workflows/build-sdk.yml @@ -0,0 +1,64 @@ +################################################################################################### +### 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: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build and pack the SDK (universal) + run : ./project/scripts/sbt dist/Universal/packageBin + - name: Build and pack the SDK (linux x86-64) + run : ./project/scripts/sbt dist-linux-x86_64/Universal/packageBin + - name: Build and pack the SDK (linux aarch64) + run : ./project/scripts/sbt dist-linux-aarch64/Universal/packageBin + - name: Build and pack the SDK (mac x86-64) + run : ./project/scripts/sbt dist-mac-x86_64/Universal/packageBin + - name: Build and pack the SDK (mac aarch64) + run : ./project/scripts/sbt dist-mac-aarch64/Universal/packageBin + - name: Build and pack the SDK (win x86-64) + run : ./project/scripts/sbt dist-win-x86_64/Universal/packageBin + - name: Upload zip archive to GitHub Artifact (universal) + uses: actions/upload-artifact@v4 + with: + path: ./dist/target/universal/scala3-*.zip + name: scala3.zip + - name: Upload zip archive to GitHub Artifact (linux x86-64) + uses: actions/upload-artifact@v4 + with: + path: ./dist/linux-x86_64/target/universal/scala3-*-x86_64-pc-linux.zip + name: scala3-x86_64-pc-linux.zip + - name: Upload zip archive to GitHub Artifact (linux aarch64) + uses: actions/upload-artifact@v4 + with: + path: ./dist/linux-aarch64/target/universal/scala3-*-aarch64-pc-linux.zip + name: scala3-aarch64-pc-linux.zip + - name: Upload zip archive to GitHub Artifact (mac x86-64) + uses: actions/upload-artifact@v4 + with: + path: ./dist/mac-x86_64/target/universal/scala3-*-x86_64-apple-darwin.zip + name: scala3-x86_64-apple-darwin.zip + - name: Upload zip archive to GitHub Artifact (mac aarch64) + uses: actions/upload-artifact@v4 + with: + path: ./dist/mac-aarch64/target/universal/scala3-*-aarch64-apple-darwin.zip + name: scala3-aarch64-apple-darwin.zip + - name: Upload zip archive to GitHub Artifact (win x86-64) + uses: actions/upload-artifact@v4 + with: + path: ./dist/win-x86_64/target/universal/scala3-*-x86_64-pc-win32.zip + name: scala3-x86_64-pc-win32.zip + \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c339649c5fb..46f4fb738c96 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1014,13 +1014,16 @@ jobs: 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 + build-chocolatey-package: uses: ./.github/workflows/build-chocolatey.yml - needs: [ build-msi-package ] + needs: [ build-sdk-package ] with: version: 3.6.0-RC1 # TODO: FIX THIS - url : ${{ needs.build-msi-package.outputs.download-url }} + url : 'https://github.com/scala/scala3/releases/download/3.5.0-RC4/scala3-3.5.0-RC4-x86_64-pc-win32.zip' # TODO: Fix this test-chocolatey-package: uses: ./.github/workflows/test-chocolatey.yml diff --git a/.github/workflows/test-chocolatey.yml b/.github/workflows/test-chocolatey.yml index d9b53ff0eb93..898580cdd5b6 100644 --- a/.github/workflows/test-chocolatey.yml +++ b/.github/workflows/test-chocolatey.yml @@ -31,6 +31,14 @@ jobs: - 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 + - 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 : Test the `scala-cli` command + run : scala-cli --version + - name : Uninstall the `scala` package + run : choco uninstall scala diff --git a/pkgs/chocolatey/tools/chocolateyInstall.ps1 b/pkgs/chocolatey/tools/chocolateyInstall.ps1 index eb4604a71fcb..c03d69b64095 100644 --- a/pkgs/chocolatey/tools/chocolateyInstall.ps1 +++ b/pkgs/chocolatey/tools/chocolateyInstall.ps1 @@ -1,13 +1,31 @@ $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' - fileType = 'MSI' - url64bit = '@LAUNCHER_URL@' + Url64 = '@LAUNCHER_URL@' + UnzipLocation = $unzipLocation +} - softwareName = 'Scala' +Install-ChocolateyZipPackage @packageArgs - silentArgs = "/qn /norestart" - validExitCodes= @(0) +$extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + +if (-not $extractedDir) { + throw "Failed to find the extracted directory." } -Install-ChocolateyPackage @packageArgs \ No newline at end of file +# Define the bin path +$scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin' # Update this path if the structure inside the ZIP changes + +# 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 +} \ No newline at end of file diff --git a/pkgs/chocolatey/tools/chocolateyUninstall.ps1 b/pkgs/chocolatey/tools/chocolateyUninstall.ps1 index e69de29bb2d1..ececbf0ab13e 100644 --- a/pkgs/chocolatey/tools/chocolateyUninstall.ps1 +++ b/pkgs/chocolatey/tools/chocolateyUninstall.ps1 @@ -0,0 +1,23 @@ +$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 + + +$extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1 + +if (-not $extractedDir) { + throw "Failed to find the extracted directory." +} + +# Define the bin path +$scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin' # Update this path if the structure inside the ZIP changes + +# 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 +}