mirror of
https://github.com/YuWanTingbb/unofficial-gpt4.git
synced 2025-10-14 06:08:06 +00:00
104 lines
3.7 KiB
YAML
104 lines
3.7 KiB
YAML
name: Build and Upload Spring Boot Native Image with Maven
|
|
|
|
on:
|
|
release:
|
|
types: [created]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Tag Name'
|
|
required: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}-${{ matrix.arch }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
arch: [arm64, amd64]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set tag name
|
|
id: tag_name
|
|
run: echo "::set-output name=tag::${{ github.event_name == 'release' && github.ref.replace('refs/tags/', '') || github.event.inputs.tag }}"
|
|
shell: bash
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v2
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'temurin'
|
|
|
|
- name: Cache Maven packages
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.m2
|
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: ${{ runner.os }}-m2
|
|
|
|
- uses: graalvm/setup-graalvm@v1
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'graalvm'
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
native-image-job-reports: 'true'
|
|
|
|
- name: Set execute permissions for mvnw
|
|
run: chmod +x ./mvnw
|
|
|
|
- name: Set UTF-8 Encoding
|
|
run: echo "JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8" >> $GITHUB_ENV
|
|
|
|
- name: Build and Rename native image with Maven
|
|
run: |
|
|
./mvnw native:compile -Pnative
|
|
mv ./target/gpt-4-copilot* ./target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
|
|
shell: bash
|
|
|
|
- name: Package the executable
|
|
run: |
|
|
mkdir packaging
|
|
cp ./target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}* ./packaging/
|
|
cp ./config.json ./packaging/config.json
|
|
shell: bash
|
|
|
|
- name: Create ZIP
|
|
run: |
|
|
cd packaging
|
|
${${ matrix.os == 'windows-latest' } && 'Compress-Archive -Path * -DestinationPath ../target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}.zip' || 'zip -r ../target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}.zip .'}
|
|
shell: ${{ matrix.os == 'windows-latest' && 'powershell' || 'bash' }}
|
|
|
|
- name: Check if release exists
|
|
id: check_release
|
|
uses: actions/github-script@v5
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const { owner, repo } = context.repo
|
|
const tag = "${{ steps.tag_name.outputs.tag }}"
|
|
let release = await github.repos.getReleaseByTag({ owner, repo, tag }).catch(() => ({ data: {} }))
|
|
return { exists: !!release.data.id, upload_url: release.data.upload_url }
|
|
|
|
- name: Create Release if not exists
|
|
if: steps.check_release.outputs.exists == 'false'
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ steps.tag_name.outputs.tag }}
|
|
release_name: Release ${{ steps.tag_name.outputs.tag }}
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Upload ZIP to Release
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.check_release.outputs.exists == 'true' && steps.check_release.outputs.upload_url || steps.create_release.outputs.upload_url }}
|
|
asset_path: ./target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}.zip
|
|
asset_name: gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}.zip
|
|
asset_content_type: application/zip
|