Update maven-cli.yml #11
Workflow file for this run
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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Java CI with Maven | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build-jar-job: | |
name: 'Build Runnable JAR' | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout from git | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Install gpg secret key | |
run: | | |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import | |
gpg --list-secret-keys --keyid-format LONG | |
- id: build_jar | |
name: Build JARs | |
env: | |
OPENEPCIS_OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OPENEPCIS_OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
run: | | |
mvn \ | |
-s .mvn/settings.xml \ | |
--no-transfer-progress \ | |
--batch-mode \ | |
clean package | |
- name: 'Get Version Number' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
run: | | |
echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" | |
- name: 'Publish JAR' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar' | |
path: 'cli/target/openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar' | |
- name: 'Create Release' | |
if: contains(github.ref, 'v') | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
tag_name: ${{github.ref}} | |
release_name: Release ${{github.ref}} | |
body: | | |
Initial release | |
draft: false | |
prerelease: false | |
- name: 'Upload Release Asset' | |
if: contains(github.ref, 'v') | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{steps.create_release.outputs.upload_url}} | |
asset_path: 'cli/target/openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar' | |
asset_name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar' | |
asset_content_type: application/java-archive | |
- name: 'Write Upload URL To File' | |
if: contains(github.ref, 'v') | |
run: | | |
echo "${{steps.create_release.outputs.upload_url}}" > upload_url.txt | |
- name: 'Publish Upload URL' | |
if: contains(github.ref, 'v') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 'upload_url.txt' | |
path: 'upload_url.txt' | |
build-non-windows-image: | |
name: 'Build Non-Windows Image' | |
needs: [build-jar-job] | |
strategy: | |
matrix: | |
os: ['ubuntu-latest', 'macos-latest'] | |
include: | |
- os: 'ubuntu-latest' | |
label: 'linux' | |
- os: 'macos-latest' | |
label: 'mac' | |
runs-on: ${{matrix.os}} | |
steps: | |
- name: checkout from git | |
uses: actions/checkout@v3 | |
- name: Set up GraalVM | |
uses: DeLaGuardo/[email protected] | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
with: | |
graalvm-version: '22.1.0.java17' | |
- name: 'Install Native Image Plugin' | |
run: | | |
gu install native-image | |
- name: 'Get Version Number' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
run: | | |
echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" | |
- name: 'Get JAR Artifact' | |
uses: actions/download-artifact@v3 | |
with: | |
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar' | |
- name: 'Download Release URL' | |
if: contains(github.ref, 'v') | |
uses: actions/download-artifact@v3 | |
with: | |
name: 'upload_url.txt' | |
- name: 'Set Upload URL Env Var' | |
if: contains(github.ref, 'v') | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
run: | | |
echo "::set-env name=UPLOAD_URL::$(cat upload_url.txt)" | |
- name: 'Build Native Image' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
run: | | |
native-image --no-server --no-fallback --enable-http --enable-https --allow-incomplete-classpath -H:+JNI -H:+UseServiceLoaderFeature -H:ReflectionConfigurationFiles=./cli/src/native/resources/reflect.json -jar openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar | |
- name: 'Publish Native Image' | |
if: success() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-${{matrix.label}}' | |
path: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies' | |
- name: 'Release Native Image Asset' | |
if: success() && contains(github.ref, 'v') | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{env.UPLOAD_URL}} | |
asset_name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-${{matrix.label}}' | |
asset_path: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies' | |
asset_content_type: application/octet-stream | |
build-windows-image: | |
needs: [build-jar-job] | |
name: 'Build Windows Image' | |
runs-on: windows-latest | |
steps: | |
- name: 'checkout from git' | |
uses: actions/checkout@v3 | |
- name: 'Download GraalVM' | |
run: | | |
Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.2.0/graalvm-ce-java17-windows-amd64-22.2.0.zip -OutFile 'graal.zip' | |
- name: 'Install GraalVM' | |
run: | | |
Expand-Archive -path 'graal.zip' -destinationpath '.' | |
- name: 'Install Native Image' | |
run: | | |
graalvm-ce-java17-22.2.0\bin\gu.cmd install native-image | |
- name: 'Set up Visual C Build Tools Workload for Visual Studio 2017 Build Tools' | |
run: | | |
choco install visualstudio2017-workload-vctools | |
- name: 'Get Version Number' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
JAVA_HOME: ./graalvm-ce-java17-22.2.0 | |
GRAALVM_HOME: ./graalvm-ce-java17-22.2.0 | |
run: | | |
echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" | |
shell: bash | |
- name: 'Get JAR Artifact' | |
uses: actions/download-artifact@v3 | |
with: | |
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar' | |
- name: 'Download Release URL' | |
if: contains(github.ref, 'v') | |
uses: actions/download-artifact@v3 | |
with: | |
name: 'upload_url.txt' | |
- name: 'Set Upload URL Env Var' | |
if: contains(github.ref, 'v') | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
run: | | |
echo "::set-env name=UPLOAD_URL::$(cat upload_url.txt)" | |
- name: 'Build Native Image' | |
shell: cmd | |
env: | |
JAVA_HOME: ./graalvm-ce-java17-22.2.0 | |
GRAALVM_HOME: ./graalvm-ce-java17-22.2.0 | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" | |
./graalvm-ce-java17-22.2.0/bin/native-image --no-server --no-fallback --enable-http --enable-https --allow-incomplete-classpath -H:+JNI -H:+UseServiceLoaderFeature -H:ReflectionConfigurationFiles=./cli/src/native/resources/reflect.json -jar openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar | |
- name: 'Publish Windows Image' | |
if: success() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-windows.exe' | |
path: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.exe' | |
- name: 'Release Windows Image Asset' | |
if: success() && contains(github.ref, 'v') | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{env.UPLOAD_URL}} | |
asset_name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-windows.exe' | |
asset_path: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.exe' | |
asset_content_type: application/octet-stream |