Skip to content

Build win native image #4

Build win native image

Build win native image #4

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-2019']
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:
version: '22.3.2'
java-version: '17'
components: 'native-image'
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 }}