Skip to content

Commit b67e186

Browse files
committed
Add workflow for Chocolatey
1 parent d0091b7 commit b67e186

File tree

6 files changed

+283
-0
lines changed

6 files changed

+283
-0
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 --out ./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.${{ inputs.version }}.nupkg
47+
if-no-files-found: error
48+

.github/workflows/build-sdk.yml

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
inputs:
17+
java-version:
18+
type : string
19+
required : true
20+
outputs:
21+
universal-id:
22+
description: ID of the `universal` package from GitHub Artifacts (Authentication Required)
23+
value : ${{ jobs.build.outputs.universal-id }}
24+
linux-x86_64-id:
25+
description: ID of the `linux x86-64` package from GitHub Artifacts (Authentication Required)
26+
value : ${{ jobs.build.outputs.linux-x86_64-id }}
27+
linux-aarch64-id:
28+
description: ID of the `linux aarch64` package from GitHub Artifacts (Authentication Required)
29+
value : ${{ jobs.build.outputs.linux-aarch64-id }}
30+
mac-x86_64-id:
31+
description: ID of the `mac x86-64` package from GitHub Artifacts (Authentication Required)
32+
value : ${{ jobs.build.outputs.mac-x86_64-id }}
33+
mac-aarch64-id:
34+
description: ID of the `mac aarch64` package from GitHub Artifacts (Authentication Required)
35+
value : ${{ jobs.build.outputs.mac-aarch64-id }}
36+
win-x86_64-id:
37+
description: ID of the `win x86-64` package from GitHub Artifacts (Authentication Required)
38+
value : ${{ jobs.build.outputs.win-x86_64-id }}
39+
40+
41+
jobs:
42+
build:
43+
runs-on: ubuntu-latest
44+
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 }}
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-java@v4
54+
with:
55+
distribution: temurin
56+
java-version: ${{ inputs.java-version }}
57+
cache : sbt
58+
- name: Build and pack the SDK (universal)
59+
run : ./project/scripts/sbt dist/Universal/stage
60+
- name: Build and pack the SDK (linux x86-64)
61+
run : ./project/scripts/sbt dist-linux-x86_64/Universal/stage
62+
- name: Build and pack the SDK (linux aarch64)
63+
run : ./project/scripts/sbt dist-linux-aarch64/Universal/stage
64+
- name: Build and pack the SDK (mac x86-64)
65+
run : ./project/scripts/sbt dist-mac-x86_64/Universal/stage
66+
- name: Build and pack the SDK (mac aarch64)
67+
run : ./project/scripts/sbt dist-mac-aarch64/Universal/stage
68+
- name: Build and pack the SDK (win x86-64)
69+
run : ./project/scripts/sbt dist-win-x86_64/Universal/stage
70+
- name: Upload zip archive to GitHub Artifact (universal)
71+
uses: actions/upload-artifact@v4
72+
id : universal
73+
with:
74+
path: ./dist/target/universal/stage
75+
name: scala3-universal
76+
- name: Upload zip archive to GitHub Artifact (linux x86-64)
77+
uses: actions/upload-artifact@v4
78+
id : linux-x86_64
79+
with:
80+
path: ./dist/linux-x86_64/target/universal/stage
81+
name: scala3-x86_64-pc-linux
82+
- name: Upload zip archive to GitHub Artifact (linux aarch64)
83+
uses: actions/upload-artifact@v4
84+
id : linux-aarch64
85+
with:
86+
path: ./dist/linux-aarch64/target/universal/stage
87+
name: scala3-aarch64-pc-linux
88+
- name: Upload zip archive to GitHub Artifact (mac x86-64)
89+
uses: actions/upload-artifact@v4
90+
id : mac-x86_64
91+
with:
92+
path: ./dist/mac-x86_64/target/universal/stage
93+
name: scala3-x86_64-apple-darwin
94+
- name: Upload zip archive to GitHub Artifact (mac aarch64)
95+
uses: actions/upload-artifact@v4
96+
id : mac-aarch64
97+
with:
98+
path: ./dist/mac-aarch64/target/universal/stage
99+
name: scala3-aarch64-apple-darwin
100+
- name: Upload zip archive to GitHub Artifact (win x86-64)
101+
uses: actions/upload-artifact@v4
102+
id : win-x86_64
103+
with:
104+
path: ./dist/win-x86_64/target/universal/stage
105+
name: scala3-x86_64-pc-win32
106+

.github/workflows/ci.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,23 @@ 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+
build-sdk-package:
1018+
uses: ./.github/workflows/build-sdk.yml
1019+
with:
1020+
java-version: 8
1021+
1022+
build-chocolatey-package:
1023+
uses: ./.github/workflows/build-chocolatey.yml
1024+
needs: [ build-sdk-package ]
1025+
with:
1026+
version: 3.6.0-local # TODO: FIX THIS
1027+
url : https://api.github.com/repos/scala/scala3/actions/artifacts/${{ needs.build-sdk-package.outputs.win-x86_64-id }}/zip
1028+
1029+
test-chocolatey-package:
1030+
uses: ./.github/workflows/test-chocolatey.yml
1031+
with:
1032+
version : 3.6.0-local # TODO: FIX THIS
1033+
java-version: 8
1034+
if: github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_chocolatey]')
1035+
needs: [ build-chocolatey-package ]
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO PUBLISH SCALA TO CHOCOLATEY ###
3+
### HOW TO USE: ###
4+
### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ###
5+
### - IT WILL PUBLISH TO CHOCOLATEY THE MSI ###
6+
### ###
7+
### NOTE: ###
8+
### - WE SHOULD KEEP IN SYNC THE NAME OF THE MSI WITH THE ACTUAL BUILD ###
9+
### - WE SHOULD KEEP IN SYNC THE URL OF THE RELEASE ###
10+
### - IT ASSUMES THAT THE `build-chocolatey` WORKFLOW WAS EXECUTED BEFORE ###
11+
###################################################################################################
12+
13+
14+
name: Publish Scala to Chocolatey
15+
run-name: Publish Scala ${{ inputs.version }} to Chocolatey
16+
17+
on:
18+
workflow_call:
19+
inputs:
20+
version:
21+
required: true
22+
type: string
23+
secrets:
24+
# Connect to https://community.chocolatey.org/profiles/scala
25+
# Accessible via https://community.chocolatey.org/account
26+
API-KEY:
27+
required: true
28+
29+
jobs:
30+
publish:
31+
runs-on: windows-latest
32+
steps:
33+
- name: Fetch the Chocolatey package from GitHub
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: scala.nupkg
37+
- name: Publish the package to Chocolatey
38+
run: choco push scala.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.API-KEY }}
39+

.github/workflows/releases.yml

+19
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,23 @@ jobs:
3737
secrets:
3838
DOTTYBOT-TOKEN: ${{ secrets.DOTTYBOT_WINGET_TOKEN }}
3939

40+
build-chocolatey:
41+
uses: ./.github/workflows/build-chocolatey.yml
42+
with:
43+
version: ${{ inputs.version }}
44+
url : 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}/scala3-${{ inputs.version }}-x86_64-pc-win32.zip'
45+
test-chocolatey:
46+
uses: ./.github/workflows/test-chocolatey.yml
47+
needs: build-chocolatey
48+
with:
49+
version : ${{ inputs.version }}
50+
java-version: 8
51+
publish-chocolatey:
52+
uses: ./.github/workflows/publish-chocolatey.yml
53+
needs: [ build-chocolatey, test-chocolatey ]
54+
with:
55+
version: ${{ inputs.version }}
56+
secrets:
57+
API-KEY: ${{ secrets.CHOCOLATEY_KEY }}
58+
4059
# TODO: ADD RELEASE WORKFLOW TO CHOCOLATEY AND OTHER PACKAGE MANAGERS HERE

.github/workflows/test-chocolatey.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
java-version:
19+
required: true
20+
type : string
21+
22+
env:
23+
CHOCOLATEY-REPOSITORY: chocolatey-pkgs
24+
DOTTY_CI_INSTALLATION: ${{ secrets.GITHUB_TOKEN }}
25+
26+
jobs:
27+
test:
28+
runs-on: windows-latest
29+
steps:
30+
- uses: actions/setup-java@v4
31+
with:
32+
distribution: temurin
33+
java-version: ${{ inputs.java-version }}
34+
- name: Download the 'nupkg' from GitHub Artifacts
35+
uses: actions/download-artifact@v4
36+
with:
37+
name: scala.nupkg
38+
path: ${{ env.CHOCOLATEY-REPOSITORY }}
39+
- name : Install the `scala` package with Chocolatey
40+
run : choco install scala --source "${{ env.CHOCOLATEY-REPOSITORY }}" --pre # --pre since we might be testing non-stable releases
41+
shell: pwsh
42+
- name : Test the `scala` command
43+
run : scala --version
44+
shell: pwsh
45+
- name : Test the `scalac` command
46+
run : scalac --version
47+
- name : Test the `scaladoc` command
48+
run : scaladoc --version
49+
- name : Uninstall the `scala` package
50+
run : choco uninstall scala
51+

0 commit comments

Comments
 (0)