Skip to content

Commit db74b7d

Browse files
committed
Update and adapt the workflows for chocolatey
1 parent 0923527 commit db74b7d

File tree

7 files changed

+113
-43
lines changed

7 files changed

+113
-43
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO BUILD SCALA WITH CHOCOLATEY ###
3+
### HOW TO USE: ###
4+
### ###
5+
### NOTE: ###
6+
### ###
7+
###################################################################################################
8+
9+
10+
name: Build 'scala' Chocolatey Package
11+
run-name: Build 'scala' (${{ inputs.version }}) Chocolatey Package
12+
13+
on:
14+
workflow_call:
15+
inputs:
16+
version:
17+
required: true
18+
type: string
19+
url:
20+
required: true
21+
type: string
22+
23+
jobs:
24+
build:
25+
runs-on: windows-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Replace the version placeholder
29+
uses: richardrigutins/replace-in-files@v2
30+
with:
31+
files: ./pkgs/chocolatey/scala.nuspec
32+
search-text: '@LAUNCHER_VERSION@'
33+
replacement-text: ${{ inputs.version }}
34+
- name: Replace the URL placeholder
35+
uses: richardrigutins/replace-in-files@v2
36+
with:
37+
files: ./pkgs/chocolatey/tools/chocolateyInstall.ps1
38+
search-text: '@LAUNCHER_URL@'
39+
replacement-text: ${{ inputs.url }}
40+
- name: Build the Chocolatey package (.nupkg)
41+
run: choco --pack ./pkgs/chocolatey/scala.nuspec --outputdirectory ./pkgs/chocolatey
42+
- name: Upload the Chocolatey package to GitHub
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: scala.nupkg
46+
path: ./pkgs/chocolatey/scala.*.nupkg
47+
if-no-files-found: error

.github/workflows/build-msi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ jobs:
3434
with:
3535
name: scala.msi
3636
path: ./dist/win-x86_64/target/windows/scala.msi
37+

.github/workflows/ci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,18 @@ jobs:
10131013
uses: ./.github/workflows/build-msi.yml
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
1016+
1017+
1018+
build-chocolatey-package:
1019+
uses: ./.github/workflows/build-chocolatey.yml
1020+
needs: [ build-msi-package ]
1021+
with:
1022+
version: 3.6.0-RC1 # TODO: FIX THIS
1023+
url : ${{ needs.build-msi-package.outputs.download-url }}
1024+
1025+
test-chocolatey-package:
1026+
uses: ./.github/workflows/test-chocolatey.yml
1027+
with:
1028+
version: 3.6.0-RC1 # TODO: FIX THIS
1029+
if: github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_chocolatey]')
1030+
needs: [ build-chocolatey-package ]

.github/workflows/publish-chocolatey.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
### NOTE: ###
88
### - WE SHOULD KEEP IN SYNC THE NAME OF THE MSI WITH THE ACTUAL BUILD ###
99
### - WE SHOULD KEEP IN SYNC THE URL OF THE RELEASE ###
10+
### - IT ASSUMES THAT THE `build-chocolatey` WORKFLOW WAS EXECUTED BEFORE ###
1011
###################################################################################################
1112

13+
1214
name: Publish Scala to Chocolatey
1315
run-name: Publish Scala ${{ inputs.version }} to Chocolatey
1416

@@ -24,51 +26,9 @@ on:
2426
API-KEY:
2527
required: true
2628

27-
env:
28-
RELEASE-URL: 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}'
29-
MSI_FILE : 'scala3-${{ inputs.version }}.msi'
30-
3129
jobs:
32-
build:
33-
runs-on: windows-latest
34-
steps:
35-
- name: Check the version of Chocolatey
36-
run : choco --version
37-
- name: Replace the version placeholder
38-
uses: richardrigutins/replace-in-files@v2
39-
with:
40-
files: ./pkgs/chocolatey/scala.nuspec
41-
search-text: '@LAUNCHER_VERSION@'
42-
replacement-text: ${{ inputs.version }}
43-
- name: Replace the URL placeholder
44-
uses: richardrigutins/replace-in-files@v2
45-
with:
46-
files: ./pkgs/chocolatey/tools/chocolateyinstall.ps1
47-
search-text: '@LAUNCHER_URL@'
48-
replacement-text: ${{ env.RELEASE-URL }}/${{ env.MSI_FILE }}
49-
- name: Build the Chocolatey package (.nupkg)
50-
run : choco --pack ./pkgs/chocolatey/scala.nuspec --outputdirectory ./pkgs/chocolatey
51-
- name: Upload the Chocolatey package to GitHub
52-
uses: actions/upload-artifact@v4
53-
with:
54-
name: scala.nupkg
55-
path: ./pkgs/chocolatey/scala.nupkg
56-
if-no-files-found: error
57-
58-
test:
59-
runs-on: windows-latest
60-
needs: build
61-
steps:
62-
- name: Fetch the Chocolatey package from GitHub
63-
uses: actions/download-artifact@v4
64-
with:
65-
name: scala.nupkg
66-
- name: Try to install the package locally
67-
run: choco install scala --debug --verbose --source .
68-
6930
publish:
7031
runs-on: windows-latest
71-
needs: [build, test]
7232
steps:
7333
- name: Fetch the Chocolatey package from GitHub
7434
uses: actions/download-artifact@v4

.github/workflows/releases.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,19 @@ jobs:
3939

4040
# TODO: ADD RELEASE WORKFLOW TO CHOCOLATEY AND OTHER PACKAGE MANAGERS HERE
4141

42+
build-chocolatey:
43+
uses: ./.github/workflows/build-chocolatey.yml
44+
with:
45+
version: ${{ inputs.version }}
46+
url : 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip'
47+
test-chocolatey:
48+
uses: ./.github/workflows/test-chocolatey.yml
49+
needs: build-chocolatey
50+
with:
51+
version: ${{ inputs.version }}
4252
publish-chocolatey:
4353
uses: ./.github/workflows/publish-chocolatey.yml
54+
needs: [ build-chocolatey, test-chocolatey ]
4455
with:
4556
version: ${{ inputs.version }}
4657
secrets:

.github/workflows/test-chocolatey.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH CHOCOLATEY ###
3+
### HOW TO USE: ###
4+
### ###
5+
### NOTE: ###
6+
### ###
7+
###################################################################################################
8+
9+
name: Test 'scala' Chocolatey Package
10+
run-name: Test 'scala' (${{ inputs.version }}) Chocolatey Package
11+
12+
on:
13+
workflow_call:
14+
inputs:
15+
version:
16+
required: true
17+
type: string
18+
19+
env:
20+
CHOCOLATEY-REPOSITORY: chocolatey-pkgs
21+
22+
jobs:
23+
test:
24+
runs-on: windows-latest
25+
steps:
26+
- name: Download the 'nupkg' from GitHub Artifacts
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: scala.nupkg
30+
path: ${{ env.CHOCOLATEY-REPOSITORY }}
31+
- name : Install the `scala` package with Chocolatey
32+
run : choco install scala --source "${{ env.CHOCOLATEY-REPOSITORY }}" --pre # --pre since we might be testing non-stable releases
33+
shell: pwsh
34+
- name : Test the scala command
35+
run : scala --version
36+
shell: pwsh

pkgs/chocolatey/tools/chocolateyinstall.ps1 renamed to pkgs/chocolatey/tools/chocolateyInstall.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$ErrorActionPreference = 'Stop';
22
$packageArgs = @{
33
packageName = 'scala'
4-
fileType = 'msi'
4+
fileType = 'MSI'
55
url64bit = '@LAUNCHER_URL@'
66

77
softwareName = 'Scala'

0 commit comments

Comments
 (0)