Skip to content

Commit 5af4908

Browse files
committed
Add support for checksums in Chocolatey
1 parent b67e186 commit 5af4908

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

Diff for: .github/workflows/build-chocolatey.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ on:
1515
inputs:
1616
version:
1717
required: true
18-
type: string
18+
type : string
1919
url:
2020
required: true
21-
type: string
21+
type : string
22+
digest:
23+
required: true
24+
type : string
2225

2326
jobs:
2427
build:
@@ -37,6 +40,12 @@ jobs:
3740
files: ./pkgs/chocolatey/tools/chocolateyInstall.ps1
3841
search-text: '@LAUNCHER_URL@'
3942
replacement-text: ${{ inputs.url }}
43+
- name: Replace the CHECKSUM placeholder
44+
uses: richardrigutins/replace-in-files@v2
45+
with:
46+
files: ./pkgs/chocolatey/tools/chocolateyInstall.ps1
47+
search-text: '@LAUNCHER_SHA256@'
48+
replacement-text: ${{ inputs.digest }}
4049
- name: Build the Chocolatey package (.nupkg)
4150
run: choco pack ./pkgs/chocolatey/scala.nuspec --out ./pkgs/chocolatey
4251
- name: Upload the Chocolatey package to GitHub

Diff for: .github/workflows/build-sdk.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,22 @@ on:
3636
win-x86_64-id:
3737
description: ID of the `win x86-64` package from GitHub Artifacts (Authentication Required)
3838
value : ${{ jobs.build.outputs.win-x86_64-id }}
39+
win-x86_64-digest:
40+
description: The SHA256 of the uploaded artifact (`win x86-64`)
41+
value : ${{ jobs.build.outputs.win-x86_64-digest }}
3942

4043

4144
jobs:
4245
build:
4346
runs-on: ubuntu-latest
4447
outputs:
45-
universal-id : ${{ steps.universal.outputs.artifact-id }}
46-
linux-x86_64-id : ${{ steps.linux-x86_64.outputs.artifact-id }}
47-
linux-aarch64-id: ${{ steps.linux-aarch64.outputs.artifact-id }}
48-
mac-x86_64-id : ${{ steps.mac-x86_64.outputs.artifact-id }}
49-
mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }}
50-
win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }}
48+
universal-id : ${{ steps.universal.outputs.artifact-id }}
49+
linux-x86_64-id : ${{ steps.linux-x86_64.outputs.artifact-id }}
50+
linux-aarch64-id : ${{ steps.linux-aarch64.outputs.artifact-id }}
51+
mac-x86_64-id : ${{ steps.mac-x86_64.outputs.artifact-id }}
52+
mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }}
53+
win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }}
54+
win-x86_64-digest: ${{ steps.win-x86_64-digest.outputs.digest }}
5155
steps:
5256
- uses: actions/checkout@v4
5357
- uses: actions/setup-java@v4
@@ -103,4 +107,10 @@ jobs:
103107
with:
104108
path: ./dist/win-x86_64/target/universal/stage
105109
name: scala3-x86_64-pc-win32
110+
- name: Compute SHA256 of the uploaded artifact (win x86-64)
111+
id : win-x86_64-digest
112+
run : |
113+
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
114+
echo "digest=$(sha256sum artifact.zip | cut -d " " -f 1)" >> "$GITHUB_OUTPUT"
115+
106116

Diff for: .github/workflows/ci.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ jobs:
10251025
with:
10261026
version: 3.6.0-local # TODO: FIX THIS
10271027
url : https://api.github.com/repos/scala/scala3/actions/artifacts/${{ needs.build-sdk-package.outputs.win-x86_64-id }}/zip
1028+
digest : ${{ needs.build-sdk-package.outputs.win-x86_64-digest }}
10281029

10291030
test-chocolatey-package:
10301031
uses: ./.github/workflows/test-chocolatey.yml

Diff for: .github/workflows/releases.yml

+13
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,24 @@ jobs:
3737
secrets:
3838
DOTTYBOT-TOKEN: ${{ secrets.DOTTYBOT_WINGET_TOKEN }}
3939

40+
compute-digest:
41+
runs-on: ubuntu-latest
42+
outputs:
43+
digest: ${{ steps.digest.outputs.digest }}
44+
steps:
45+
- name: Compute the SHA256 of scala3-${{ inputs.version }}-x86_64-pc-win32.zip in GitHub Release
46+
id: digest
47+
run: |
48+
curl -o artifact.zip -L https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip
49+
echo "digest=$(sha256sum artifact.zip | cut -d " " -f 1)" >> "$GITHUB_OUTPUT"
50+
4051
build-chocolatey:
4152
uses: ./.github/workflows/build-chocolatey.yml
53+
needs: compute-digest
4254
with:
4355
version: ${{ inputs.version }}
4456
url : 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip'
57+
digest : ${{ needs.compute-digest.outputs.digest }}
4558
test-chocolatey:
4659
uses: ./.github/workflows/test-chocolatey.yml
4760
needs: build-chocolatey

Diff for: pkgs/chocolatey/tools/chocolateyInstall.ps1

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ $unzipLocation = Join-Path $unzipLocation "$($env:chocolateyPackageVersion)" #
66

77
# Configure the installation arguments
88
$packageArgs = @{
9-
packageName = 'scala'
10-
Url64 = '@LAUNCHER_URL@'
11-
UnzipLocation = $unzipLocation
9+
packageName = 'scala'
10+
Url64 = '@LAUNCHER_URL@'
11+
UnzipLocation = $unzipLocation
12+
Checksum64 = '@LAUNCHER_SHA256@'
13+
ChecksumType64 = 'SHA256'
1214
}
1315

1416
## In case we are running in the CI, add the authorisation header to fetch the zip

0 commit comments

Comments
 (0)