-
Notifications
You must be signed in to change notification settings - Fork 235
145 lines (142 loc) · 5.74 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
scalaVersion: ['2.12.19', '2.13.14', '3.3.3', '3.4.2']
javaTag: [
'graalvm-community-22.0.0',
'graalvm-community-21.0.2',
'graalvm-ce-22.3.3-b1-java17',
'eclipse-temurin-jammy-22_36',
'eclipse-temurin-jammy-21.0.2_13',
'eclipse-temurin-jammy-17.0.10_7',
'eclipse-temurin-alpine-22_36',
'eclipse-temurin-alpine-21.0.2_13',
'eclipse-temurin-alpine-17.0.10_7'
]
include:
# https://github.com/graalvm/container/pkgs/container/graalvm-community
- javaTag: 'graalvm-community-22.0.0'
dockerContext: 'graalvm-community'
baseImageTag: '22.0.0-ol9'
platforms: 'linux/amd64,linux/arm64'
- javaTag: 'graalvm-community-21.0.2'
dockerContext: 'graalvm-community'
baseImageTag: '21.0.2-ol9'
platforms: 'linux/amd64,linux/arm64'
# https://github.com/graalvm/container/pkgs/container/graalvm-ce
- javaTag: 'graalvm-ce-22.3.3-b1-java17'
dockerContext: 'graalvm-ce'
baseImageTag: 'ol9-java17-22.3.3-b1'
platforms: 'linux/amd64,linux/arm64'
# https://hub.docker.com/_/eclipse-temurin/tags
- javaTag: 'eclipse-temurin-jammy-22_36'
dockerContext: 'eclipse-temurin'
baseImageTag: '22_36-jdk-jammy'
platforms: 'linux/amd64,linux/arm64'
- javaTag: 'eclipse-temurin-jammy-21.0.2_13'
dockerContext: 'eclipse-temurin'
baseImageTag: '21.0.2_13-jdk-jammy'
platforms: 'linux/amd64,linux/arm64'
- javaTag: 'eclipse-temurin-jammy-17.0.10_7'
dockerContext: 'eclipse-temurin'
baseImageTag: '17.0.10_7-jdk-jammy'
platforms: 'linux/amd64,linux/arm64'
# https://hub.docker.com/_/eclipse-temurin/tags?page=1&name=alpine
- javaTag: 'eclipse-temurin-alpine-22_36'
dockerContext: 'eclipse-temurin'
dockerfile: 'alpine.Dockerfile'
baseImageTag: '22_36-jdk-alpine'
platforms: 'linux/amd64,linux/arm64/v8'
- javaTag: 'eclipse-temurin-alpine-21.0.2_13'
dockerContext: 'eclipse-temurin'
dockerfile: 'alpine.Dockerfile'
baseImageTag: '21.0.2_13-jdk-alpine'
platforms: 'linux/amd64,linux/arm64/v8'
- javaTag: 'eclipse-temurin-alpine-17.0.10_7'
dockerContext: 'eclipse-temurin'
dockerfile: 'alpine.Dockerfile'
baseImageTag: '17.0.10_7-jdk-alpine'
platforms: 'linux/amd64'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
# with:
# install: true
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Get latest SBT version
id: get_sbt_version
run: |
SBT_VERSION=$(
curl --silent -L https://github.com/sbt/sbt/releases |
grep -i -w -o '>[0-9]*\.[0-9]*\.[0-9]*</a>' |
grep -i -w -o '[0-9]*\.[0-9]*\.[0-9]*' |
sort --version-sort | tail -n 1)
[[ -z "$SBT_VERSION" ]] && { echo "Failed to get latest sbt version" ; exit 1; }
echo "VERSION=$SBT_VERSION" >> $GITHUB_OUTPUT
- name: Create docker tag
id: create_docker_tag
run: |
TAG=sbtscala/scala-sbt:${{ matrix.javaTag }}_${{ steps.get_sbt_version.outputs.VERSION }}_${{ matrix.scalaVersion }}
echo "TAG=$TAG" >> $GITHUB_OUTPUT
- name: Build docker image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.dockerContext }}
no-cache: true
tags: ${{ steps.create_docker_tag.outputs.TAG }}
file: ${{ matrix.dockerContext }}/${{ matrix.dockerfile || 'Dockerfile' }}
build-args: |
BASE_IMAGE_TAG=${{ matrix.baseImageTag }}
SBT_VERSION=${{ steps.get_sbt_version.outputs.VERSION }}
SCALA_VERSION=${{ matrix.scalaVersion }}
load: true
- name: Test docker image as root (default)
if: ${{ !startsWith(matrix.scalaVersion, '2.12') }}
# scala --version does not work on < 2.13
run: |
docker run "${{ steps.create_docker_tag.outputs.TAG }}" \
scala --version &&
sbt about
- name: Test docker image scala as sbtuser
if: ${{ !startsWith(matrix.scalaVersion, '2.12') }}
# scala --version does not work on < 2.13
run: |
docker run -u sbtuser -w /home/sbtuser "${{ steps.create_docker_tag.outputs.TAG }}" \
scala --version &&
sbt about
- name: Log in to DockerHub
if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Rebuild and push ${{ matrix.platforms }} docker images
if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'
uses: docker/build-push-action@v6
with:
context: ${{ matrix.dockerContext }}
file: ${{ matrix.dockerContext }}/${{ matrix.dockerfile || 'Dockerfile' }}
tags: ${{ steps.create_docker_tag.outputs.TAG }}
build-args: |
BASE_IMAGE_TAG=${{ matrix.baseImageTag }}
SBT_VERSION=${{ steps.get_sbt_version.outputs.VERSION }}
SCALA_VERSION=${{ matrix.scalaVersion }}
platforms: ${{ matrix.platforms }}
push: true