mirror of
https://github.com/YuWanTingbb/unofficial-gpt4.git
synced 2025-10-14 14:11:23 +00:00
99 lines
3.3 KiB
YAML
99 lines
3.3 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 }}
|
|
strategy:
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set tag name
|
|
id: tag_name
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "release" ]; then
|
|
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
|
|
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
|
|
fi
|
|
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: Build native image with Maven
|
|
run: |
|
|
./mvnw native:compile -Pnative
|
|
if ("${{ matrix.os }}" -eq "windows-latest") {
|
|
mv ./target/gpt-4-copilot.exe ./target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}.exe
|
|
} else {
|
|
mv ./target/gpt-4-copilot ./target/gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}
|
|
}
|
|
shell: pwsh
|
|
|
|
- name: Check if release exists
|
|
id: check_release
|
|
run: |
|
|
RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.tag_name.outputs.tag }}) || true
|
|
if echo "$RELEASE" | grep -q '"id":'; then
|
|
echo "::set-output name=exists::true"
|
|
UPLOAD_URL=$(echo "$RELEASE" | jq -r .upload_url)
|
|
echo "::set-output name=upload_url::${UPLOAD_URL}"
|
|
else
|
|
echo "::set-output name=exists::false"
|
|
fi
|
|
shell: bash
|
|
|
|
- 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 native image 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.os == 'windows-latest' ? '.exe' : '' }}
|
|
asset_name: gpt-4-copilot-${{ steps.tag_name.outputs.tag }}-${{ matrix.os }}${{ matrix.os == 'windows-latest' ? '.exe' : '' }}
|
|
asset_content_type: application/octet-stream
|