-
-
Notifications
You must be signed in to change notification settings - Fork 178
147 lines (131 loc) · 4.78 KB
/
Copy pathnative-image.yml
File metadata and controls
147 lines (131 loc) · 4.78 KB
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
146
147
name: Native Image
on:
# Called by other workflows (e.g. tags.yml on release branches)
workflow_call:
inputs:
version:
description: "Version to release. Leave empty for snapshot build."
required: false
type: string
default: ""
# Manual trigger
workflow_dispatch:
inputs:
version:
description: "Version to release. Leave empty for snapshot build."
required: false
type: string
default: ""
jobs:
build-and-upload:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: linux-amd64
- os: windows-latest
arch: windows-amd64
- os: macos-latest
arch: "darwin-arm64"
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- uses: graalvm/setup-graalvm@v1
with:
version: '25.1'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
native-image-job-reports: 'true'
- name: Build MacOS Apple Silicon native
if: matrix.arch == 'darwin-arm64'
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image -march=list
export MAVEN_OPTS="-Xmx8g -Xms4g"
mvn package -Pnative -DskipTests \
-Dnative.march="-march=armv8-a" \
-Dquarkus.native.additional-build-args="-J-Xmx6g,-J-Xms4g,--gc=serial"
- name: Build Windows native
if: matrix.arch == 'windows-amd64'
run: |
echo "GRAALVM_HOME: %GRAALVM_HOME%"
echo "JAVA_HOME: %JAVA_HOME%"
java --version
native-image.cmd -march=list
mvn package -Pnative -DskipTests "-Dnative.march=-march=x86-64"
- name: Build Linux native
if: matrix.arch == 'linux-amd64'
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image -march=list
mvn package -Pnative -DskipTests -Dnative.march="-march=x86-64"
chmod +x core/target/restheart
- name: Upload native artifact
uses: actions/upload-artifact@v6
with:
name: restheart-${{ matrix.arch }}
path: ${{ matrix.arch == 'windows-amd64' && 'core/target/restheart.exe' || 'core/target/restheart' }}
overwrite: true
- name: Upload to release
if: inputs.version != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SRC=${{ matrix.arch == 'windows-amd64' && 'core/target/restheart.exe' || 'core/target/restheart' }}
DST="restheart-${{ matrix.arch }}${{ matrix.arch == 'windows-amd64' && '.exe' || '' }}"
cp "$SRC" "/tmp/$DST"
gh release upload "${{ inputs.version }}" "/tmp/$DST" --clobber
docker-publish-linux:
runs-on: ubuntu-latest
needs: build-and-upload
steps:
- uses: actions/checkout@v6
- name: Download native artifact
uses: actions/download-artifact@v5
with:
name: restheart-linux-amd64
path: core/target/
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set snapshot tags
if: inputs.version == ''
run: |
SHA=$(echo ${GITHUB_SHA:0:7})
TAGS="softinstigate/restheart-snapshot:${SHA}-native"
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
TAGS="${TAGS},softinstigate/restheart-snapshot:latest-native"
fi
echo "TAGS=${TAGS}" >> $GITHUB_ENV
- name: Set release tags
if: inputs.version != ''
run: |
VERSION="${{ inputs.version }}"
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1)
MINOR=$(echo "$VERSION" | cut -d '.' -f 2)
PATCH=$(echo "$VERSION" | cut -d '.' -f 3)
echo "TAGS=softinstigate/restheart:latest-native,softinstigate/restheart:${MAJOR}-native,softinstigate/restheart:${MAJOR}.${MINOR}-native,softinstigate/restheart:${MAJOR}.${MINOR}.${PATCH}-native" >> $GITHUB_ENV
- name: Build and push multi-arch native Docker images
uses: docker/build-push-action@v7
with:
context: ./core/
file: ./core/Dockerfile.native
# Dockerfile.native copies a pre-built linux-amd64 binary.
# Multi-arch requires cross-compilation or per-platform builds.
platforms: linux/amd64
push: true
pull: true
tags: ${{ env.TAGS }}