Build win native image #8
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
name: Build win native image | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
# 'ubuntu-latest', 'windows-latest', 'macos-latest' | |
os: ['windows-2022'] | |
name: build - ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
# https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128 | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: GitHub Action for GraalVM JDK 17 | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '17.0.7' # for a specific JDK 17; or '17' for the latest JDK 17 | |
distribution: 'graalvm' # New 'distribution' option | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache local Maven repository | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Set vars | |
shell: bash | |
run: | | |
OS=$(echo '${{ runner.os }}' | awk '{print tolower($0)}') | |
[[ $OS == 'ubuntu' ]] && echo "OS=linux" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV | |
[[ $OS == 'macos' ]] && echo "OS=darwin" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV | |
echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
- name: Build with Maven | |
run: | | |
set MAVEN_OPTS="-Duser.language=UTF-8 -Dfile.encoding=UTF-8" | |
mvn clean install -DskipTests -pl common -am --no-transfer-progress | |
cd app-runner | |
mvn clean native:compile -P native --no-transfer-progress | |
cp app-runner/target/app.exe ./../app.exe | |
# 压缩文件 | |
- name: Archive zip | |
uses: thedoctor0/zip-release@master | |
with: | |
type: 'zip' | |
path: 'app.exe' | |
filename: app-${{ env.OS }} | |
# 上传构建产物 | |
- name: Upload artifact | |
uses: actions/[email protected] | |
with: | |
name: app-${{ env.OS }}.zip | |
path: app-${{ env.OS }}.zip | |
# GitHub 上创建 release | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
app-${{ env.OS }}.zip | |
app-runner/target/app.jar | |
prerelease: true | |
token: ${{ secrets.GITHUB_TOKEN }} |