Skip to content

Commit 129a1d1

Browse files
committed
Implement Chocolatey package with zip not msi
1 parent db74b7d commit 129a1d1

File tree

6 files changed

+126
-10
lines changed

6 files changed

+126
-10
lines changed

.github/workflows/build-chocolatey.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
search-text: '@LAUNCHER_URL@'
3939
replacement-text: ${{ inputs.url }}
4040
- name: Build the Chocolatey package (.nupkg)
41-
run: choco --pack ./pkgs/chocolatey/scala.nuspec --outputdirectory ./pkgs/chocolatey
41+
run: choco pack ./pkgs/chocolatey/scala.nuspec --out ./pkgs/chocolatey
4242
- name: Upload the Chocolatey package to GitHub
4343
uses: actions/upload-artifact@v4
4444
with:

.github/workflows/build-sdk.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO BUILD THE SCALA LAUNCHERS ###
3+
### HOW TO USE: ###
4+
### - THSI WORKFLOW WILL PACKAGE THE ALL THE LAUNCHERS AND UPLOAD THEM TO GITHUB ARTIFACTS ###
5+
### ###
6+
### NOTE: ###
7+
### - SEE THE WORFLOW FOR THE NAMES OF THE ARTIFACTS ###
8+
###################################################################################################
9+
10+
11+
name: Build Scala Launchers
12+
run-name: Build Scala Launchers
13+
14+
on:
15+
workflow_call:
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Build and pack the SDK (universal)
23+
run : ./project/scripts/sbt dist/Universal/packageBin
24+
- name: Build and pack the SDK (linux x86-64)
25+
run : ./project/scripts/sbt dist-linux-x86_64/Universal/packageBin
26+
- name: Build and pack the SDK (linux aarch64)
27+
run : ./project/scripts/sbt dist-linux-aarch64/Universal/packageBin
28+
- name: Build and pack the SDK (mac x86-64)
29+
run : ./project/scripts/sbt dist-mac-x86_64/Universal/packageBin
30+
- name: Build and pack the SDK (mac aarch64)
31+
run : ./project/scripts/sbt dist-mac-aarch64/Universal/packageBin
32+
- name: Build and pack the SDK (win x86-64)
33+
run : ./project/scripts/sbt dist-win-x86_64/Universal/packageBin
34+
- name: Upload zip archive to GitHub Artifact (universal)
35+
uses: actions/upload-artifact@v4
36+
with:
37+
path: ./dist/target/universal/scala3-*.zip
38+
name: scala3.zip
39+
- name: Upload zip archive to GitHub Artifact (linux x86-64)
40+
uses: actions/upload-artifact@v4
41+
with:
42+
path: ./dist/linux-x86_64/target/universal/scala3-*-x86_64-pc-linux.zip
43+
name: scala3-x86_64-pc-linux.zip
44+
- name: Upload zip archive to GitHub Artifact (linux aarch64)
45+
uses: actions/upload-artifact@v4
46+
with:
47+
path: ./dist/linux-aarch64/target/universal/scala3-*-aarch64-pc-linux.zip
48+
name: scala3-aarch64-pc-linux.zip
49+
- name: Upload zip archive to GitHub Artifact (mac x86-64)
50+
uses: actions/upload-artifact@v4
51+
with:
52+
path: ./dist/mac-x86_64/target/universal/scala3-*-x86_64-apple-darwin.zip
53+
name: scala3-x86_64-apple-darwin.zip
54+
- name: Upload zip archive to GitHub Artifact (mac aarch64)
55+
uses: actions/upload-artifact@v4
56+
with:
57+
path: ./dist/mac-aarch64/target/universal/scala3-*-aarch64-apple-darwin.zip
58+
name: scala3-aarch64-apple-darwin.zip
59+
- name: Upload zip archive to GitHub Artifact (win x86-64)
60+
uses: actions/upload-artifact@v4
61+
with:
62+
path: ./dist/win-x86_64/target/universal/scala3-*-x86_64-pc-win32.zip
63+
name: scala3-x86_64-pc-win32.zip
64+

.github/workflows/ci.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1014,13 +1014,16 @@ jobs:
10141014
if : github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]')
10151015
# TODO: ADD A JOB THAT DEPENDS ON THIS TO TEST THE MSI
10161016

1017+
build-sdk-package:
1018+
uses: ./.github/workflows/build-sdk.yml
1019+
10171020

10181021
build-chocolatey-package:
10191022
uses: ./.github/workflows/build-chocolatey.yml
1020-
needs: [ build-msi-package ]
1023+
needs: [ build-sdk-package ]
10211024
with:
10221025
version: 3.6.0-RC1 # TODO: FIX THIS
1023-
url : ${{ needs.build-msi-package.outputs.download-url }}
1026+
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
10241027

10251028
test-chocolatey-package:
10261029
uses: ./.github/workflows/test-chocolatey.yml

.github/workflows/test-chocolatey.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ jobs:
3131
- name : Install the `scala` package with Chocolatey
3232
run : choco install scala --source "${{ env.CHOCOLATEY-REPOSITORY }}" --pre # --pre since we might be testing non-stable releases
3333
shell: pwsh
34-
- name : Test the scala command
34+
- name : Test the `scala` command
3535
run : scala --version
3636
shell: pwsh
37+
- name : Test the `scalac` command
38+
run : scalac --version
39+
- name : Test the `scaladoc` command
40+
run : scaladoc --version
41+
- name : Test the `scala-cli` command
42+
run : scala-cli --version
43+
- name : Uninstall the `scala` package
44+
run : choco uninstall scala
+24-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
$ErrorActionPreference = 'Stop';
2+
3+
$unzipLocation = Split-Path -Parent $MyInvocation.MyCommand.Definition # Get the root of chocolatey folder
4+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageName)" # Append the package's name
5+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # Append the package's version
6+
7+
# Configure the installation arguments
28
$packageArgs = @{
39
packageName = 'scala'
4-
fileType = 'MSI'
5-
url64bit = '@LAUNCHER_URL@'
10+
Url64 = '@LAUNCHER_URL@'
11+
UnzipLocation = $unzipLocation
12+
}
613

7-
softwareName = 'Scala'
14+
Install-ChocolateyZipPackage @packageArgs
815

9-
silentArgs = "/qn /norestart"
10-
validExitCodes= @(0)
16+
$extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1
17+
18+
if (-not $extractedDir) {
19+
throw "Failed to find the extracted directory."
1120
}
1221

13-
Install-ChocolateyPackage @packageArgs
22+
# Define the bin path
23+
$scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin' # Update this path if the structure inside the ZIP changes
24+
25+
# Iterate through the .bat files in the bin directory and create shims
26+
Write-Host "Creating shims for .bat file from $scalaBinPath"
27+
Get-ChildItem -Path $scalaBinPath -Filter '*.bat' | ForEach-Object {
28+
$file = $_.FullName
29+
Write-Host "Creating shim for $file..."
30+
Install-BinFile -Name $_.BaseName -Path $file
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$ErrorActionPreference = 'Stop';
2+
3+
$unzipLocation = Split-Path -Parent $MyInvocation.MyCommand.Definition # Get the root of chocolatey folder
4+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageName)" # Append the package's name
5+
$unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" # Append the package's version
6+
7+
8+
$extractedDir = Get-ChildItem -Path $unzipLocation | Where-Object { $_.PSIsContainer } | Select-Object -First 1
9+
10+
if (-not $extractedDir) {
11+
throw "Failed to find the extracted directory."
12+
}
13+
14+
# Define the bin path
15+
$scalaBinPath = Join-Path $unzipLocation $extractedDir | Join-Path -ChildPath 'bin' # Update this path if the structure inside the ZIP changes
16+
17+
# Iterate through the .bat files in the bin directory and remove shims
18+
Write-Host "Removing shims for .bat file from $scalaBinPath"
19+
Get-ChildItem -Path $scalaBinPath -Filter '*.bat' | ForEach-Object {
20+
$file = $_.FullName
21+
Write-Host "Removing shim for $file..."
22+
Uninstall-BinFile -Name $_.BaseName -Path $file
23+
}

0 commit comments

Comments
 (0)