Skip to content

Build linux and mac native image #3

Build linux and mac native image

Build linux and mac native image #3

name: Build linux and mac native image
on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
build:
strategy:
fail-fast: false
matrix:
# 'ubuntu-latest', 'windows-latest', 'macos-latest'
# os: ['ubuntu-20.04', 'macos-12']
os: ['ubuntu-20.04']
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
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: |
export MAVEN_OPTS="-Duser.language=zh -Duser.region=CN -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 target/app ./../app
# 压缩文件
- name: Archive zip
uses: thedoctor0/zip-release@master
with:
type: 'zip'
path: 'app'
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 }}