forked from pepijnve/ditaa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes pepijnve#12 build native images
- Loading branch information
1 parent
cdff0ee
commit dc6b24e
Showing
2 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
name: Native Images On-Demand | ||
|
||
run-name: Native Images ${{ inputs.tag }} by @${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build_artifacts: | ||
outputs: | ||
release_version: ${{ steps.version.outputs.release_version }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set release version | ||
id: version | ||
env: | ||
REF: ${{ github.event.inputs.tag }} | ||
run: | | ||
echo "release_version=${REF#v}" >> $GITHUB_ENV | ||
echo "release_version=${REF#v}" >> $GITHUB_OUTPUT | ||
- name: Checkout the repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: "refs/tags/mini-${{ github.event.inputs.tag }}" | ||
|
||
- name: Set up java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: temurin | ||
cache: gradle | ||
|
||
- name: Set version from tag | ||
env: | ||
RELEASE_VERSION: ${{ env.release_version }} | ||
run: sed -i "s/version = .*/version = $RELEASE_VERSION/" gradle.properties | ||
|
||
- name: Build artifacts | ||
run: | | ||
./gradlew build | ||
- name: Cache libs | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
build/libs | ||
key: "libs-${{ github.run_id }}" | ||
enableCrossOsArchive: true | ||
|
||
native_images: | ||
needs: build_artifacts | ||
uses: ./.github/workflows/native-image.yml | ||
with: | ||
release-version: ${{ needs.build_artifacts.outputs.release_version }} | ||
|
||
native_arm_image: | ||
needs: build_artifacts | ||
runs-on: [ self-hosted, ARM64 ] | ||
steps: | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: '22.3.1' | ||
java-version: '11' | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- run: | | ||
rm -rf ./build/libs | ||
- uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
build/libs | ||
key: "libs-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Generate GraalVM configuration | ||
run: | | ||
mkdir -p native-image-config-dir | ||
printf '+--+--------+ | ||
| | | | ||
| | | | ||
| | /---+ | ||
| | | | | ||
| | | | | ||
+--+----+---/' | java -agentlib:native-image-agent=config-output-dir=native-image-config-dir -jar "./build/libs/ditaamini-$RELEASE_VERSION.jar" --svg - | ||
printf '+--+--------+ | ||
| | | | ||
| | | | ||
| | /---+ | ||
| | | | | ||
| | | | | ||
+--+----+---/' | java -agentlib:native-image-agent=config-output-dir=native-image-config-dir -jar "./build/libs/ditaamini-$RELEASE_VERSION.jar" - | ||
env: | ||
RELEASE_VERSION: ${{ needs.build_artifacts.outputs.release_version }} | ||
|
||
- name: Generate native image | ||
run: | | ||
native-image -H:ConfigurationFileDirectories=native-image-config-dir --no-fallback --report-unsupported-elements-at-runtime -jar "build/libs/ditaamini-$RELEASE_VERSION.jar" -H:Path="build/libs" -H:Name="ditaamini-linux-arm64-$RELEASE_VERSION" | ||
env: | ||
RELEASE_VERSION: ${{ needs.build_artifacts.outputs.release_version }} | ||
|
||
- name: Cache native image | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: "build/libs/ditaamini-linux-arm64-*" | ||
key: "native-image-linux-arm64-${{ github.run_id }}" | ||
enableCrossOsArchive: true | ||
|
||
upload: | ||
needs: [ build_artifacts, native_images, native_arm_image ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Restore Libs cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
build/libs | ||
key: "libs-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Restore Native-image-darwin-amd64 cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: "build/libs/ditaamini-darwin-amd64-*" | ||
key: "native-image-darwin-amd64-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Restore Native-image-win-amd64 cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: "build/libs/ditaamini-win-amd64-*" | ||
key: "native-image-win-amd64-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Restore Native-image-linux-amd64 cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: "build/libs/ditaamini-linux-amd64-*" | ||
key: "native-image-linux-amd64-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Restore Native-image-linux-arm64 cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: "build/libs/ditaamini-linux-arm64-*" | ||
key: "native-image-linux-arm64-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Create release | ||
run: | | ||
gh release view "$RELEASE_VERSION" || gh release create "$RELEASE_VERSION" | ||
gh release upload "$RELEASE_VERSION" ./build/libs/ditaamini-darwin-* ./build/libs/ditaamini-linux-* ./build/libs/ditaamini-win-* --clobber | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE_VERSION: ${{ needs.build_artifacts.outputs.release_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Native Image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release-version: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build_non_win_images: | ||
name: 'Build Native Image ${{ matrix.platform }}' | ||
strategy: | ||
matrix: | ||
os: [ macos-latest, windows-latest, ubuntu-latest ] | ||
include: | ||
- os: 'ubuntu-latest' | ||
platform: 'linux-amd64' | ||
- os: 'macos-latest' | ||
platform: 'darwin-amd64' | ||
- os: 'windows-latest' | ||
platform: 'win-amd64' | ||
runs-on: ${{matrix.os}} | ||
steps: | ||
- uses: graalvm/setup-graalvm@v1 | ||
with: | ||
version: '22.3.1' | ||
java-version: '11' | ||
components: 'native-image' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
build/libs | ||
key: "libs-${{ github.run_id }}" | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Generate GraalVM configuration | ||
run: | | ||
mkdir -p native-image-config-dir | ||
printf '+--+--------+ | ||
| | | | ||
| | | | ||
| | /---+ | ||
| | | | | ||
| | | | | ||
+--+----+---/' | java -agentlib:native-image-agent=config-output-dir=native-image-config-dir -jar "./build/libs/ditaamini-${{ inputs.release-version }}.jar" --svg - | ||
printf '+--+--------+ | ||
| | | | ||
| | | | ||
| | /---+ | ||
| | | | | ||
| | | | | ||
+--+----+---/' | java -agentlib:native-image-agent=config-output-dir=native-image-config-dir -jar "./build/libs/ditaamini-${{ inputs.release-version }}.jar" - | ||
- name: Generate native image | ||
run: | | ||
native-image -H:ConfigurationFileDirectories=native-image-config-dir --no-fallback --report-unsupported-elements-at-runtime -jar "build/libs/ditaamini-${{ inputs.release-version }}.jar" -H:Path="build/libs" -H:Name="ditaamini-${{ matrix.platform }}-${{ inputs.release-version }}" | ||
- name: Cache native image | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: "build/libs/ditaamini-${{ matrix.platform }}-*" | ||
key: "native-image-${{ matrix.platform }}-${{ github.run_id }}" | ||
enableCrossOsArchive: true |