109 lines
4.7 KiB
YAML
109 lines
4.7 KiB
YAML
name: Build linux and mac native image
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# see: https://docs.github.com/zh/actions/using-jobs/choosing-the-runner-for-a-job
|
|
# os: ['ubuntu-20.04', 'macos-12']
|
|
os: ['ubuntu-latest']
|
|
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: setup node v13.12.0
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 13.12.0
|
|
# cache: 'npm' # 使用缓存需要把 package-lock.json 也上传到 git 上
|
|
- name: build neutrino-proxy-admin
|
|
run: |
|
|
cd neutrino-proxy-admin
|
|
npm install
|
|
npm run build:docker
|
|
cp -rf ./dist/ ./../neutrino-proxy-server/src/main/resources/static/
|
|
- name: GitHub Action for GraalVM JDK 21
|
|
uses: graalvm/setup-graalvm@v1
|
|
with:
|
|
java-version: '21.0.1' # for a specific JDK 21
|
|
distribution: 'graalvm' # New 'distribution' option
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Cache local Maven repository
|
|
uses: actions/cache@v4
|
|
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 (neutrino-proxy-server)
|
|
run: |
|
|
mvn clean install -pl neutrino-proxy-core -am -DskipTests --no-transfer-progress
|
|
cd neutrino-proxy-server
|
|
mvn clean native:compile -P native --file pom.xml --no-transfer-progress
|
|
chmod +x target/neutrino-proxy-server
|
|
mkdir ./../neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native
|
|
cp target/neutrino-proxy-server ./../neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native/neutrino-proxy-server
|
|
cp target/classes/app-copy.yml ./../neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native/app.yml
|
|
- name: Archive zip (neutrino-proxy-server)
|
|
uses: thedoctor0/zip-release@master
|
|
with:
|
|
type: 'zip'
|
|
path: 'neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native'
|
|
filename: neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native.zip
|
|
- name: Build with Maven (neutrino-proxy-client)
|
|
run: |
|
|
cd neutrino-proxy-client
|
|
mvn clean package --file pom.xml --no-transfer-progress
|
|
mvn clean native:compile -P native --file pom.xml --no-transfer-progress
|
|
chmod +x target/neutrino-proxy-client
|
|
mkdir ./../neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native
|
|
cp target/neutrino-proxy-client ./../neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native/neutrino-proxy-client
|
|
cp target/classes/app-copy.yml ./../neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native/app.yml
|
|
- name: Archive zip (neutrino-proxy-client)
|
|
uses: thedoctor0/zip-release@master
|
|
with:
|
|
type: 'zip'
|
|
path: 'neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native'
|
|
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native.zip
|
|
# 上传构建产物
|
|
- name: Upload artifact
|
|
uses: actions/[email protected]
|
|
with:
|
|
name: neutrino-proxy-server-client-${{ env.OS }}-${{ env.VERSION }}
|
|
path: |
|
|
neutrino-proxy-server/target/neutrino-proxy-server.jar
|
|
neutrino-proxy-client/target/neutrino-proxy-client.jar
|
|
neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native.zip
|
|
neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native.zip
|
|
# 保存时间,默认 90 天
|
|
retention-days: 5
|
|
# GitHub 上创建 release
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
files: |
|
|
neutrino-proxy-server/target/neutrino-proxy-server.jar
|
|
neutrino-proxy-client/target/neutrino-proxy-client.jar
|
|
neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}-native.zip
|
|
neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native.zip
|
|
prerelease: true
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|