Skip to content

Commit 97b627f

Browse files
committed
Add deb and rpm packages
1 parent 7e87811 commit 97b627f

8 files changed

Lines changed: 420 additions & 5 deletions

File tree

.github/workflows/build-deb.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO BUILD SCALA DEB ###
3+
### HOW TO USE: ###
4+
### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ###
5+
### - IT WILL UPLOAD TO GITHUB THE DEB FILE FOR SCALA UNDER THE 'scala.deb' NAME ###
6+
### ###
7+
### NOTE: ###
8+
### - SCALA 3.8.0+ IS DISTRIBUTED USING JAVA 17 ###
9+
###################################################################################################
10+
11+
name: Build the Debian Package
12+
13+
on:
14+
workflow_call:
15+
outputs:
16+
version:
17+
description: 'The developed Scala version (major.minor.patch) extracted from project/Build.scala'
18+
value: ${{ jobs.build.outputs.version }}
19+
20+
env:
21+
# Release only happens when triggering CI by pushing a tag
22+
RELEASEBUILD: ${{ startsWith(github.event.ref, 'refs/tags/') && 'yes' || 'no' }}
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
version: ${{ steps.extract-version.outputs.version }}
29+
steps:
30+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
32+
with:
33+
distribution: temurin
34+
java-version: 17
35+
cache: sbt
36+
- uses: sbt/setup-sbt@bfea3c5f48abd221b04a6df4798aa5eb8b6a2baf # v1.5.6
37+
- name: Ensure Debian build tooling
38+
run: |
39+
command -v dpkg-deb >/dev/null && command -v fakeroot >/dev/null \
40+
|| (sudo apt-get update && sudo apt-get install -y --no-install-recommends dpkg-dev fakeroot)
41+
- name: Extract Scala version
42+
id: extract-version
43+
shell: bash
44+
run: |
45+
version=$(sed -n 's/.*val developedVersion = "\(.*\)".*/\1/p' project/Build.scala)
46+
echo "version=$version" >> "$GITHUB_OUTPUT"
47+
echo "Extracted Scala version: $version"
48+
- name: Build the .deb package
49+
run: ./project/scripts/sbt "dist-linux-x86_64-deb/Debian/packageBin"
50+
- name: Upload deb Artifact
51+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
52+
with:
53+
name: scala.deb
54+
path: ./dist/linux-x86_64-deb/target/scala.deb

.github/workflows/build-rpm.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO BUILD SCALA RPM ###
3+
### HOW TO USE: ###
4+
### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ###
5+
### - IT WILL UPLOAD TO GITHUB THE RPM FILE FOR SCALA UNDER THE 'scala.rpm' NAME ###
6+
### ###
7+
### NOTE: ###
8+
### - SCALA 3.8.0+ IS DISTRIBUTED USING JAVA 17 ###
9+
### - rpmbuild is provided by the `rpm` apt package (cross-distro build tool) ###
10+
###################################################################################################
11+
12+
name: Build the RPM Package
13+
14+
on:
15+
workflow_call:
16+
outputs:
17+
version:
18+
description: 'The developed Scala version (major.minor.patch) extracted from project/Build.scala'
19+
value: ${{ jobs.build.outputs.version }}
20+
21+
env:
22+
# Release only happens when triggering CI by pushing a tag
23+
RELEASEBUILD: ${{ startsWith(github.event.ref, 'refs/tags/') && 'yes' || 'no' }}
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
version: ${{ steps.extract-version.outputs.version }}
30+
steps:
31+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32+
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
33+
with:
34+
distribution: temurin
35+
java-version: 17
36+
cache: sbt
37+
- uses: sbt/setup-sbt@bfea3c5f48abd221b04a6df4798aa5eb8b6a2baf # v1.5.6
38+
- name: Ensure RPM build tooling
39+
run: command -v rpmbuild >/dev/null || (sudo apt-get update && sudo apt-get install -y rpm)
40+
- name: Extract Scala version
41+
id: extract-version
42+
shell: bash
43+
run: |
44+
version=$(sed -n 's/.*val developedVersion = "\(.*\)".*/\1/p' project/Build.scala)
45+
echo "version=$version" >> "$GITHUB_OUTPUT"
46+
echo "Extracted Scala version: $version"
47+
- name: Build the .rpm package
48+
run: ./project/scripts/sbt "dist-linux-x86_64-rpm/Rpm/packageBin"
49+
- name: Upload rpm Artifact
50+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
51+
with:
52+
name: scala.rpm
53+
path: ./dist/linux-x86_64-rpm/target/rpm/scala.rpm

.github/workflows/ci.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,30 @@ jobs:
222222
mv scala.msi "${msiInstaller}"
223223
sha256sum "${msiInstaller}" > "${msiInstaller}.sha256"
224224
225+
- name: Download deb package
226+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
227+
with:
228+
name: scala.deb
229+
path: .
230+
- name: Prepare deb package
231+
shell: bash
232+
run: |
233+
debInstaller="scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.deb"
234+
mv scala.deb "${debInstaller}"
235+
sha256sum "${debInstaller}" > "${debInstaller}.sha256"
236+
237+
- name: Download rpm package
238+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
239+
with:
240+
name: scala.rpm
241+
path: .
242+
- name: Prepare rpm package
243+
shell: bash
244+
run: |
245+
rpmInstaller="scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.rpm"
246+
mv scala.rpm "${rpmInstaller}"
247+
sha256sum "${rpmInstaller}" > "${rpmInstaller}.sha256"
248+
225249
- name: Install GH CLI
226250
uses: dev-hanz-ops/install-gh-cli-action@af38ce09b1ec248aeb08eea2b16bbecea9e059f8 # v0.2.1
227251
with:
@@ -251,6 +275,8 @@ jobs:
251275
--verify-tag ${{ env.RELEASE_TAG }} \
252276
scala3-${{ env.RELEASE_TAG }}*.zip \
253277
scala3-${{ env.RELEASE_TAG }}*.tar.gz \
278+
scala3-${{ env.RELEASE_TAG }}*.deb \
279+
scala3-${{ env.RELEASE_TAG }}*.rpm \
254280
scala3-${{ env.RELEASE_TAG }}*.sha256 \
255281
scala3-${{ env.RELEASE_TAG }}.msi
256282
@@ -379,6 +405,30 @@ jobs:
379405
version: ${{ needs.build-msi-package.outputs.version }}
380406
java-version: 17
381407

408+
build-deb-package:
409+
uses: ./.github/workflows/build-deb.yml
410+
if :
411+
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_deb]')) ||
412+
(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/'))
413+
414+
test-deb-package:
415+
uses: ./.github/workflows/test-deb.yml
416+
needs: [build-deb-package]
417+
with:
418+
version: ${{ needs.build-deb-package.outputs.version }}
419+
420+
build-rpm-package:
421+
uses: ./.github/workflows/build-rpm.yml
422+
if :
423+
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_rpm]')) ||
424+
(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/'))
425+
426+
test-rpm-package:
427+
uses: ./.github/workflows/test-rpm.yml
428+
needs: [build-rpm-package]
429+
with:
430+
version: ${{ needs.build-rpm-package.outputs.version }}
431+
382432
build-sdk-package:
383433
uses: ./.github/workflows/build-sdk.yml
384434
permissions:

.github/workflows/test-deb.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH DEB RUNNER ###
3+
### HOW TO USE: ###
4+
### `version` is the expected Scala version; the installed scala/scalac/scaladoc ###
5+
### are asserted to report it, then a program is compiled and run. ###
6+
### NOTE: Requires `scala.deb` artifact uploaded within the same run ###
7+
### ###
8+
###################################################################################################
9+
10+
name: Test 'scala' Debian Package
11+
run-name: Test 'scala' (${{ inputs.version }}) Debian Package
12+
13+
on:
14+
workflow_call:
15+
inputs:
16+
version:
17+
required: true
18+
type: string
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
image:
27+
- debian:12
28+
- debian:13
29+
- ubuntu:22.04
30+
- ubuntu:24.04
31+
container: ${{ matrix.image }}
32+
env:
33+
VERSION: ${{ inputs.version }}
34+
steps:
35+
- name: Download deb artifact
36+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
37+
with:
38+
name: scala.deb
39+
path: .
40+
41+
- name: Install Scala Runner
42+
run: |
43+
apt-get update
44+
apt-get install -y ./scala.deb
45+
46+
- name: Verify installation layout
47+
run: |
48+
set -e
49+
echo "Checking /usr/bin/scala symlink..."
50+
test -L /usr/bin/scala
51+
test "$(readlink -f /usr/bin/scala)" = /usr/share/scala3/bin/scala
52+
53+
echo "Checking VERSION file..."
54+
test -f /usr/share/scala3/VERSION
55+
cat /usr/share/scala3/VERSION
56+
57+
echo "Checking scala-cli launcher..."
58+
test -x /usr/share/scala3/libexec/scala-cli
59+
60+
echo "Checking maven2 directory..."
61+
test -d /usr/share/scala3/maven2
62+
63+
- name: Test Scala Runner
64+
run: |
65+
out="$(scala --version)"; echo "$out"
66+
echo "$out" | grep -qF "Scala version (default): $VERSION"
67+
- name: Test the `scalac` command
68+
run: |
69+
out="$(scalac --version)"; echo "$out"
70+
echo "$out" | grep -qF "Scala compiler version $VERSION"
71+
- name: Test the `scaladoc` command
72+
run: |
73+
out="$(scaladoc --version)"; echo "$out"
74+
echo "$out" | grep -qF "Scaladoc version $VERSION"
75+
76+
- name: Smoke test - compile and run
77+
run: |
78+
echo '@main def test() = println("Hello from Scala")' > test.scala
79+
scala run --server=false test.scala
80+
81+
- name: Uninstall the `scala` package
82+
run: apt-get remove -y scala3

.github/workflows/test-rpm.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH RPM RUNNER ###
3+
### HOW TO USE: ###
4+
### `version` is the expected Scala version; the installed scala/scalac/scaladoc ###
5+
### are asserted to report it, then a program is compiled and run. ###
6+
### NOTE: Requires `scala.rpm` artifact uploaded within the same run ###
7+
### ###
8+
###################################################################################################
9+
10+
name: Test 'scala' RPM Package
11+
run-name: Test 'scala' (${{ inputs.version }}) RPM Package
12+
13+
on:
14+
workflow_call:
15+
inputs:
16+
version:
17+
required: true
18+
type: string
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
image:
27+
- fedora:43
28+
- fedora:latest
29+
- almalinux:9
30+
- almalinux:10
31+
- opensuse/leap:16.0
32+
- opensuse/tumbleweed
33+
container: ${{ matrix.image }}
34+
env:
35+
VERSION: ${{ inputs.version }}
36+
steps:
37+
- name: Download rpm artifact
38+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
39+
with:
40+
name: scala.rpm
41+
path: .
42+
43+
- name: Install Scala Runner
44+
run: |
45+
if command -v dnf >/dev/null; then
46+
dnf install -y ./scala.rpm
47+
elif command -v zypper >/dev/null; then
48+
zypper --non-interactive --gpg-auto-import-keys refresh
49+
zypper --non-interactive install --allow-unsigned-rpm ./scala.rpm
50+
else
51+
echo "No supported package manager (dnf/zypper) found"; exit 1
52+
fi
53+
54+
- name: Verify installation layout
55+
run: |
56+
set -e
57+
echo "Checking /usr/bin/scala symlink..."
58+
test -L /usr/bin/scala
59+
test "$(readlink -f /usr/bin/scala)" = /usr/share/scala3/bin/scala
60+
61+
echo "Checking VERSION file..."
62+
test -f /usr/share/scala3/VERSION
63+
cat /usr/share/scala3/VERSION
64+
65+
echo "Checking scala-cli launcher..."
66+
test -x /usr/share/scala3/libexec/scala-cli
67+
68+
echo "Checking maven2 directory..."
69+
test -d /usr/share/scala3/maven2
70+
71+
- name: Test Scala Runner
72+
run: |
73+
out="$(scala --version)"; echo "$out"
74+
echo "$out" | grep -qF "Scala version (default): $VERSION"
75+
- name: Test the `scalac` command
76+
run: |
77+
out="$(scalac --version)"; echo "$out"
78+
echo "$out" | grep -qF "Scala compiler version $VERSION"
79+
- name: Test the `scaladoc` command
80+
run: |
81+
out="$(scaladoc --version)"; echo "$out"
82+
echo "$out" | grep -qF "Scaladoc version $VERSION"
83+
84+
- name: Smoke test - compile and run
85+
run: |
86+
echo '@main def test() = println("Hello from Scala")' > test.scala
87+
scala run --server=false test.scala
88+
89+
- name: Uninstall the `scala` package
90+
run: |
91+
if command -v dnf >/dev/null; then
92+
dnf remove -y scala3
93+
elif command -v zypper >/dev/null; then
94+
zypper --non-interactive remove scala3
95+
fi

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ val `dist-mac-x86_64` = Build.`dist-mac-x86_64`
4242
val `dist-mac-aarch64` = Build.`dist-mac-aarch64`
4343
val `dist-win-x86_64` = Build.`dist-win-x86_64`
4444
val `dist-linux-x86_64` = Build.`dist-linux-x86_64`
45+
val `dist-linux-x86_64-deb` = Build.`dist-linux-x86_64-deb`
46+
val `dist-linux-x86_64-rpm` = Build.`dist-linux-x86_64-rpm`
4547
val `dist-linux-aarch64` = Build.`dist-linux-aarch64`
4648
val `community-build` = Build.`community-build`
4749
val `scala3-presentation-compiler` = Build.`scala3-presentation-compiler`

0 commit comments

Comments
 (0)