Build linux and mac native image #2
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 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: | | |
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 }} |