mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-14 17:53:05 +08:00
Compare commits
13 Commits
release-co
...
release-ct
| Author | SHA1 | Date | |
|---|---|---|---|
| 9054a9b4ad | |||
|
|
c8d5f577a1 | ||
| 7c82c4aea5 | |||
| 5491ad1747 | |||
| 1be6ed0198 | |||
| 01bfc3ee18 | |||
| 2d45adf8c3 | |||
| 707fddda79 | |||
| 68589a21fc | |||
| e8228d0cc1 | |||
| cc99e565f0 | |||
|
|
718271417d | ||
| 04ee38726b |
18
.github/workflows/release-core.yml
vendored
18
.github/workflows/release-core.yml
vendored
@@ -4,12 +4,12 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: "Release tag, for example rel-v0.5.0"
|
description: "Core release tag, for example release-core/0.5.0"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "rel-v*"
|
- "release-core/*"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -29,18 +29,20 @@ jobs:
|
|||||||
TAG="${GITHUB_REF_NAME}"
|
TAG="${GITHUB_REF_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION="${TAG#rel-v}"
|
VERSION="${TAG#release-core/}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
ENCODED_TAG="${TAG//\//%2F}"
|
||||||
ASSET_NAME="partner-core-${VERSION}.jar"
|
ASSET_NAME="partner-core-${VERSION}.jar"
|
||||||
ASSET_URL="https://github.com/slhaf/Partner/releases/download/${TAG}/${ASSET_NAME}"
|
ASSET_URL="https://github.com/slhaf/Partner/releases/download/${ENCODED_TAG}/${ASSET_NAME}"
|
||||||
|
|
||||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
echo "asset_name=${ASSET_NAME}" >> "$GITHUB_OUTPUT"
|
echo "asset_name=${ASSET_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
echo "asset_url=${ASSET_URL}" >> "$GITHUB_OUTPUT"
|
echo "asset_url=${ASSET_URL}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
echo "Release tag: ${TAG}"
|
echo "Core release tag: ${TAG}"
|
||||||
echo "Release version: ${VERSION}"
|
echo "Core release version: ${VERSION}"
|
||||||
echo "Release asset: ${ASSET_NAME}"
|
echo "Core release asset: ${ASSET_NAME}"
|
||||||
|
|
||||||
- name: Checkout release source
|
- name: Checkout release source
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -84,7 +86,7 @@ jobs:
|
|||||||
|
|
||||||
gh release create "${{ steps.release.outputs.tag }}" \
|
gh release create "${{ steps.release.outputs.tag }}" \
|
||||||
"dist/${{ steps.release.outputs.asset_name }}" \
|
"dist/${{ steps.release.outputs.asset_name }}" \
|
||||||
--title "${{ steps.release.outputs.tag }}" \
|
--title "Partner Core ${{ steps.release.outputs.version }}" \
|
||||||
--notes "Partner Core ${{ steps.release.outputs.version }}"
|
--notes "Partner Core ${{ steps.release.outputs.version }}"
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|||||||
161
.github/workflows/release-ctl.yml
vendored
Normal file
161
.github/workflows/release-ctl.yml
vendored
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
name: Release PartnerCtl
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Ctl release tag, for example release-ctl/0.5.0"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "release-ctl/*"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build ${{ matrix.platform }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: linux-x64
|
||||||
|
runner: ubuntu-latest
|
||||||
|
binaryPath: PartnerCtl/target/partnerctl
|
||||||
|
assetSuffix: linux-x64
|
||||||
|
- platform: linux-arm64
|
||||||
|
runner: ubuntu-24.04-arm
|
||||||
|
binaryPath: PartnerCtl/target/partnerctl
|
||||||
|
assetSuffix: linux-arm64
|
||||||
|
- platform: windows-x64
|
||||||
|
runner: windows-latest
|
||||||
|
binaryPath: PartnerCtl/target/partnerctl.exe
|
||||||
|
assetSuffix: windows-x64.exe
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Resolve release metadata
|
||||||
|
id: release
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
TAG="${{ inputs.tag }}"
|
||||||
|
else
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION="${TAG#release-ctl/}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
ASSET_NAME="partnerctl-${VERSION}-${{ matrix.assetSuffix }}"
|
||||||
|
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "asset_name=${ASSET_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "Ctl release tag: ${TAG}"
|
||||||
|
echo "Ctl release version: ${VERSION}"
|
||||||
|
echo "Ctl release asset: ${ASSET_NAME}"
|
||||||
|
|
||||||
|
- name: Checkout release source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ steps.release.outputs.tag }}
|
||||||
|
|
||||||
|
- name: Set up GraalVM 21
|
||||||
|
uses: graalvm/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
distribution: graalvm-community
|
||||||
|
java-version: "21"
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build partnerctl native image
|
||||||
|
run: mvn -B -DskipTests=true -pl PartnerCtl -am package native:compile
|
||||||
|
|
||||||
|
- name: Prepare release artifact
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p dist
|
||||||
|
|
||||||
|
BINARY_PATH="${{ matrix.binaryPath }}"
|
||||||
|
ASSET_PATH="dist/${{ steps.release.outputs.asset_name }}"
|
||||||
|
|
||||||
|
if [ ! -f "$BINARY_PATH" ]; then
|
||||||
|
echo "Expected native binary not found: $BINARY_PATH"
|
||||||
|
echo "Available PartnerCtl target files:"
|
||||||
|
find PartnerCtl/target -maxdepth 2 -type f -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp "$BINARY_PATH" "$ASSET_PATH"
|
||||||
|
|
||||||
|
if [[ "${{ matrix.platform }}" == linux-* ]]; then
|
||||||
|
chmod +x "$ASSET_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ls -lh dist
|
||||||
|
|
||||||
|
- name: Upload release artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ steps.release.outputs.asset_name }}
|
||||||
|
path: dist/${{ steps.release.outputs.asset_name }}
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Create GitHub Release
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Resolve release metadata
|
||||||
|
id: release
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
TAG="${{ inputs.tag }}"
|
||||||
|
else
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION="${TAG#release-ctl/}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "Ctl release tag: ${TAG}"
|
||||||
|
echo "Ctl release version: ${VERSION}"
|
||||||
|
|
||||||
|
- name: Checkout release source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ steps.release.outputs.tag }}
|
||||||
|
|
||||||
|
- name: Download release artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Show release artifacts
|
||||||
|
run: |
|
||||||
|
ls -lh dist
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if gh release view "${{ steps.release.outputs.tag }}" >/dev/null 2>&1; then
|
||||||
|
echo "Release ${{ steps.release.outputs.tag }} already exists."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh release create "${{ steps.release.outputs.tag }}" \
|
||||||
|
dist/* \
|
||||||
|
--title "PartnerCtl ${{ steps.release.outputs.version }}" \
|
||||||
|
--notes "PartnerCtl ${{ steps.release.outputs.version }}"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
137
.github/workflows/test-partnerctl-native.yml
vendored
Normal file
137
.github/workflows/test-partnerctl-native.yml
vendored
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
name: Test PartnerCtl Native Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
platform:
|
||||||
|
description: "Target platform to test"
|
||||||
|
required: true
|
||||||
|
default: "windows-x64"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- windows-x64
|
||||||
|
- linux-x64
|
||||||
|
- linux-arm64
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-linux-x64:
|
||||||
|
name: Test linux-x64
|
||||||
|
if: ${{ inputs.platform == 'linux-x64' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up GraalVM 21
|
||||||
|
uses: graalvm/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
distribution: graalvm-community
|
||||||
|
java-version: "21"
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build partnerctl native image
|
||||||
|
run: mvn -B -DskipTests=true -pl PartnerCtl -am package native:compile
|
||||||
|
|
||||||
|
- name: Check Linux output
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ ! -f "PartnerCtl/target/partnerctl" ]; then
|
||||||
|
echo "Expected native binary not found: PartnerCtl/target/partnerctl"
|
||||||
|
echo "Available PartnerCtl target files:"
|
||||||
|
find PartnerCtl/target -maxdepth 2 -type f -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod +x PartnerCtl/target/partnerctl
|
||||||
|
./PartnerCtl/target/partnerctl --help
|
||||||
|
|
||||||
|
- name: Upload test artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: partnerctl-linux-x64-test
|
||||||
|
path: PartnerCtl/target/partnerctl
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
test-linux-arm64:
|
||||||
|
name: Test linux-arm64
|
||||||
|
if: ${{ inputs.platform == 'linux-arm64' }}
|
||||||
|
runs-on: ubuntu-24.04-arm
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up GraalVM 21
|
||||||
|
uses: graalvm/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
distribution: graalvm-community
|
||||||
|
java-version: "21"
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build partnerctl native image
|
||||||
|
run: mvn -B -DskipTests=true -pl PartnerCtl -am package native:compile
|
||||||
|
|
||||||
|
- name: Check Linux output
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ ! -f "PartnerCtl/target/partnerctl" ]; then
|
||||||
|
echo "Expected native binary not found: PartnerCtl/target/partnerctl"
|
||||||
|
echo "Available PartnerCtl target files:"
|
||||||
|
find PartnerCtl/target -maxdepth 2 -type f -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod +x PartnerCtl/target/partnerctl
|
||||||
|
./PartnerCtl/target/partnerctl --help
|
||||||
|
|
||||||
|
- name: Upload test artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: partnerctl-linux-arm64-test
|
||||||
|
path: PartnerCtl/target/partnerctl
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
test-windows-x64:
|
||||||
|
name: Test windows-x64
|
||||||
|
if: ${{ inputs.platform == 'windows-x64' }}
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up GraalVM 21
|
||||||
|
uses: graalvm/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
distribution: graalvm-community
|
||||||
|
java-version: "21"
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build partnerctl native image
|
||||||
|
run: mvn -B -DskipTests=true -pl PartnerCtl -am package native:compile
|
||||||
|
|
||||||
|
- name: Check Windows output
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
if (!(Test-Path "PartnerCtl/target/partnerctl.exe")) {
|
||||||
|
Write-Host "Expected native binary not found: PartnerCtl/target/partnerctl.exe"
|
||||||
|
Write-Host "Available PartnerCtl target files:"
|
||||||
|
Get-ChildItem -Recurse PartnerCtl/target | Select-Object FullName
|
||||||
|
throw "partnerctl.exe not found"
|
||||||
|
}
|
||||||
|
|
||||||
|
.\PartnerCtl\target\partnerctl.exe --help
|
||||||
|
|
||||||
|
- name: Upload test artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: partnerctl-windows-x64-test
|
||||||
|
path: PartnerCtl/target/partnerctl.exe
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
37
.idea/misc.xml
generated
37
.idea/misc.xml
generated
@@ -1,28 +1,29 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<list size="21">
|
<list size="22">
|
||||||
<item index="0" class="java.lang.String" itemvalue="lombok.Data" />
|
<item index="0" class="java.lang.String" itemvalue="lombok.Data" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="net.bytebuddy.implementation.bind.annotation.RuntimeType" />
|
<item index="1" class="java.lang.String" itemvalue="net.bytebuddy.implementation.bind.annotation.RuntimeType" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="picocli.CommandLine.Command" />
|
<item index="2" class="java.lang.String" itemvalue="picocli.CommandLine.Command" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="picocli.CommandLine.Mixin" />
|
<item index="3" class="java.lang.String" itemvalue="picocli.CommandLine.Mixin" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.Capability" />
|
<item index="4" class="java.lang.String" itemvalue="picocli.CommandLine.Option" />
|
||||||
<item index="5" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.CapabilityCore" />
|
<item index="5" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.Capability" />
|
||||||
<item index="6" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.CapabilityMethod" />
|
<item index="6" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.CapabilityCore" />
|
||||||
<item index="7" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.CoordinateManager" />
|
<item index="7" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.CapabilityMethod" />
|
||||||
<item index="8" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.Coordinated" />
|
<item index="8" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.CoordinateManager" />
|
||||||
<item index="9" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.component.annotation.Init" />
|
<item index="9" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.capability.annotation.Coordinated" />
|
||||||
<item index="10" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.AfterExecute" />
|
<item index="10" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.component.annotation.Init" />
|
||||||
<item index="11" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.AgentRunningModule" />
|
<item index="11" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.AfterExecute" />
|
||||||
<item index="12" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.AgentSubModule" />
|
<item index="12" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.AgentRunningModule" />
|
||||||
<item index="13" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.BeforeExecute" />
|
<item index="13" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.AgentSubModule" />
|
||||||
<item index="14" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.Init" />
|
<item index="14" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.BeforeExecute" />
|
||||||
<item index="15" class="java.lang.String" itemvalue="work.slhaf.partner.api.capability.annotation.CapabilityMethod" />
|
<item index="15" class="java.lang.String" itemvalue="work.slhaf.partner.api.agent.factory.module.annotation.Init" />
|
||||||
<item index="16" class="java.lang.String" itemvalue="work.slhaf.partner.api.capability.annotation.CoordinateManager" />
|
<item index="16" class="java.lang.String" itemvalue="work.slhaf.partner.api.capability.annotation.CapabilityMethod" />
|
||||||
<item index="17" class="java.lang.String" itemvalue="work.slhaf.partner.api.register.capability.annotation.Capability" />
|
<item index="17" class="java.lang.String" itemvalue="work.slhaf.partner.api.capability.annotation.CoordinateManager" />
|
||||||
<item index="18" class="java.lang.String" itemvalue="work.slhaf.partner.framework.agent.factory.capability.annotation.CapabilityCore" />
|
<item index="18" class="java.lang.String" itemvalue="work.slhaf.partner.api.register.capability.annotation.Capability" />
|
||||||
<item index="19" class="java.lang.String" itemvalue="work.slhaf.partner.framework.agent.factory.capability.annotation.CapabilityMethod" />
|
<item index="19" class="java.lang.String" itemvalue="work.slhaf.partner.framework.agent.factory.capability.annotation.CapabilityCore" />
|
||||||
<item index="20" class="java.lang.String" itemvalue="work.slhaf.partner.framework.agent.factory.component.annotation.AgentComponent" />
|
<item index="20" class="java.lang.String" itemvalue="work.slhaf.partner.framework.agent.factory.capability.annotation.CapabilityMethod" />
|
||||||
|
<item index="21" class="java.lang.String" itemvalue="work.slhaf.partner.framework.agent.factory.component.annotation.AgentComponent" />
|
||||||
</list>
|
</list>
|
||||||
<writeAnnotations>
|
<writeAnnotations>
|
||||||
<writeAnnotation name="work.slhaf.partner.api.agent.factory.capability.annotation.InjectCapability" />
|
<writeAnnotation name="work.slhaf.partner.api.agent.factory.capability.annotation.InjectCapability" />
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner</artifactId>
|
<artifactId>partner</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>partner-core</artifactId>
|
<artifactId>partner-core</artifactId>
|
||||||
|
<version>0.5.0</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner-framework</artifactId>
|
<artifactId>partner-framework</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>${partner.runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.nd4j/nd4j-api -->
|
<!-- https://mvnrepository.com/artifact/org.nd4j/nd4j-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -6,22 +6,23 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner-external-modules</artifactId>
|
<artifactId>partner-external-modules</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>partner-onebot-adapter</artifactId>
|
<artifactId>partner-onebot-adapter</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner-core</artifactId>
|
<artifactId>partner-core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${partner.runtime.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner-framework</artifactId>
|
<artifactId>partner-framework</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${partner.runtime.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner</artifactId>
|
<artifactId>partner</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>partner-external-modules</artifactId>
|
<artifactId>partner-external-modules</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner</artifactId>
|
<artifactId>partner</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>partner-framework</artifactId>
|
<artifactId>partner-framework</artifactId>
|
||||||
|
<version>0.5.0</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -86,7 +87,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner-interaction-api</artifactId>
|
<artifactId>partner-interaction-api</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>${partner.interaction-api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner</artifactId>
|
<artifactId>partner</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>partner-interaction-api</artifactId>
|
<artifactId>partner-interaction-api</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner</artifactId>
|
<artifactId>partner</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>partnerctl</artifactId>
|
<artifactId>partnerctl</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner-interaction-api</artifactId>
|
<artifactId>partner-interaction-api</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>${partner.interaction-api.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ fun configureExternalGateway(home: Path, prompt: Prompt, manifest: ModuleManifes
|
|||||||
text("configure.gateway.external.details.buildCommand") to manifest.source.buildCommand.joinToString(" "),
|
text("configure.gateway.external.details.buildCommand") to manifest.source.buildCommand.joinToString(" "),
|
||||||
text("configure.gateway.external.details.artifact") to "${manifest.source.artifactDirectory}/${manifest.source.artifactPattern}",
|
text("configure.gateway.external.details.artifact") to "${manifest.source.artifactDirectory}/${manifest.source.artifactPattern}",
|
||||||
text("configure.gateway.external.details.installTarget") to manifest.install.target,
|
text("configure.gateway.external.details.installTarget") to manifest.install.target,
|
||||||
text("configure.gateway.external.details.configTarget") to (manifest.config?.target ?: text("configure.gateway.external.details.noConfig")),
|
text("configure.gateway.external.details.configTarget") to (manifest.config?.target
|
||||||
|
?: text("configure.gateway.external.details.noConfig")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -138,18 +139,43 @@ private fun askField(prompt: Prompt, field: Field): JsonElement? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("KotlinConstantConditions")
|
|
||||||
private fun validateFieldValue(field: Field, value: String): String? {
|
private fun validateFieldValue(field: Field, value: String): String? {
|
||||||
if (value.isBlank() && !field.required) return null
|
if (value.isBlank() && !field.required) return null
|
||||||
|
|
||||||
return when (field.type) {
|
return when (field.type) {
|
||||||
FieldType.STRING -> null
|
FieldType.STRING -> null
|
||||||
FieldType.INT -> value.toIntOrNull()?.let { null } ?: text("configure.field.error.int", field.label)
|
FieldType.INT -> {
|
||||||
FieldType.NUMBER -> value.toDoubleOrNull()?.let { null } ?: text("configure.field.error.number", field.label)
|
if (value.toIntOrNull() == null) {
|
||||||
FieldType.BOOLEAN -> value.toBooleanStrictOrNull()?.let { null } ?: text("configure.field.error.boolean", field.label)
|
text("configure.field.error.int", field.label)
|
||||||
FieldType.RAW_JSON -> runCatching { Json.parseToJsonElement(value) }
|
} else {
|
||||||
.exceptionOrNull()
|
null
|
||||||
?.let { text("configure.field.error.rawJson", field.label) }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldType.NUMBER -> {
|
||||||
|
if (value.toDoubleOrNull() == null) {
|
||||||
|
text("configure.field.error.number", field.label)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldType.BOOLEAN -> {
|
||||||
|
if (value.toBooleanStrictOrNull() == null) {
|
||||||
|
text("configure.field.error.boolean", field.label)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldType.RAW_JSON -> {
|
||||||
|
val result = runCatching { Json.parseToJsonElement(value) }.exceptionOrNull()
|
||||||
|
if (result == null) {
|
||||||
|
text("configure.field.error.rawJson", field.label)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.nio.file.Paths
|
|||||||
import kotlin.io.path.isDirectory
|
import kotlin.io.path.isDirectory
|
||||||
import kotlin.io.path.name
|
import kotlin.io.path.name
|
||||||
|
|
||||||
private const val PARTNER_REPO_URL = "https://gitea.slhaf.work/slhaf/Partner.git"
|
private const val PARTNER_REPO_URL = "https://github.com/slhaf/Partner.git"
|
||||||
|
|
||||||
fun buildFromSource(home: Path, prompt: Prompt) {
|
fun buildFromSource(home: Path, prompt: Prompt) {
|
||||||
buildAndInstallFromSource(
|
buildAndInstallFromSource(
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
package work.slhaf.partner.ctl.support
|
package work.slhaf.partner.ctl.support
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
private const val registryUrl = "https://raw.githubusercontent.com/slhaf/Partner/refs/heads/master/registry"
|
||||||
|
private const val indexUrl = "$registryUrl/index.json"
|
||||||
|
|
||||||
|
private val registryIndex = run {
|
||||||
|
Json.decodeFromString<RegistryIndex>(fetchText(indexUrl))
|
||||||
|
}
|
||||||
|
|
||||||
private fun loadModules(): Set<ModuleManifest> {
|
private fun loadModules(): Set<ModuleManifest> {
|
||||||
// TODO: 待实现具体加载逻辑
|
return registryIndex.externalModules.map { indexItem ->
|
||||||
return emptySet()
|
val manifestStr = fetchText("$registryUrl/${indexItem.registryRef}")
|
||||||
|
return@map Json.decodeFromString<ModuleManifest>(manifestStr)
|
||||||
|
}.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadAvailableGateway(): Set<ModuleManifest> {
|
fun loadAvailableGateway(): Set<ModuleManifest> {
|
||||||
@@ -92,3 +102,35 @@ enum class FieldType {
|
|||||||
BOOLEAN,
|
BOOLEAN,
|
||||||
RAW_JSON,
|
RAW_JSON,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegistryIndex(
|
||||||
|
val partner: PartnerIndex,
|
||||||
|
val externalModules: List<ModulesIndexItem>
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PartnerIndex(
|
||||||
|
val latestBuildable: Buildable,
|
||||||
|
val latestRelease: Release
|
||||||
|
) {
|
||||||
|
@Serializable
|
||||||
|
data class Buildable(
|
||||||
|
val url: String,
|
||||||
|
val ref: String
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Release(
|
||||||
|
val url: String,
|
||||||
|
val version: String
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ModulesIndexItem(
|
||||||
|
val name: String,
|
||||||
|
val version: String,
|
||||||
|
val withGateway: Boolean,
|
||||||
|
val registryRef: String
|
||||||
|
)
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package work.slhaf.partner.ctl.support
|
||||||
|
|
||||||
|
import java.io.IOException
|
||||||
|
import java.net.InetSocketAddress
|
||||||
|
import java.net.ProxySelector
|
||||||
|
import java.net.URI
|
||||||
|
import java.net.http.*
|
||||||
|
import java.time.Duration
|
||||||
|
|
||||||
|
private val httpClient: HttpClient = HttpClient.newBuilder()
|
||||||
|
.connectTimeout(Duration.ofSeconds(20))
|
||||||
|
.followRedirects(HttpClient.Redirect.NEVER)
|
||||||
|
.apply {
|
||||||
|
proxySelectorFromEnv()?.let(::proxy)
|
||||||
|
}
|
||||||
|
.build()
|
||||||
|
|
||||||
|
private fun proxySelectorFromEnv(): ProxySelector? {
|
||||||
|
val proxyText = System.getenv("HTTPS_PROXY")
|
||||||
|
?: System.getenv("https_proxy")
|
||||||
|
?: return null
|
||||||
|
|
||||||
|
val proxyUri = URI.create(proxyText)
|
||||||
|
val host = proxyUri.host
|
||||||
|
?: throw IllegalArgumentException("Invalid HTTPS_PROXY host: $proxyText")
|
||||||
|
|
||||||
|
val port = proxyUri.port
|
||||||
|
if (port == -1) {
|
||||||
|
throw IllegalArgumentException("HTTPS_PROXY must include port: $proxyText")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ProxySelector.of(InetSocketAddress(host, port))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fetchText(url: String): String {
|
||||||
|
var lastError: Exception? = null
|
||||||
|
|
||||||
|
repeat(3) { attempt ->
|
||||||
|
try {
|
||||||
|
val request = HttpRequest.newBuilder()
|
||||||
|
.uri(URI.create(url))
|
||||||
|
.timeout(Duration.ofSeconds(60))
|
||||||
|
.header("User-Agent", "partnerctl")
|
||||||
|
.GET()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val response = httpClient.send(
|
||||||
|
request,
|
||||||
|
HttpResponse.BodyHandlers.ofString()
|
||||||
|
)
|
||||||
|
|
||||||
|
if (response.statusCode() !in 200..299) {
|
||||||
|
throw IOException("Failed to fetch $url: HTTP ${response.statusCode()}")
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.body()
|
||||||
|
} catch (e: HttpTimeoutException) {
|
||||||
|
lastError = e
|
||||||
|
} catch (e: HttpConnectTimeoutException) {
|
||||||
|
lastError = e
|
||||||
|
} catch (e: IOException) {
|
||||||
|
lastError = e
|
||||||
|
} catch (e: InterruptedException) {
|
||||||
|
Thread.currentThread().interrupt()
|
||||||
|
throw IOException("Interrupted while fetching $url", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attempt < 2) {
|
||||||
|
Thread.sleep(500L * (attempt + 1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw IOException("Failed to fetch $url after retries", lastError)
|
||||||
|
}
|
||||||
12
PartnerCtl/src/test/java/experimental/WebFetchTest.kt
Normal file
12
PartnerCtl/src/test/java/experimental/WebFetchTest.kt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package experimental
|
||||||
|
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import work.slhaf.partner.ctl.support.RegistryIndex
|
||||||
|
import work.slhaf.partner.ctl.support.fetchText
|
||||||
|
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val str = fetchText("https://raw.githubusercontent.com/slhaf/Partner/refs/heads/master/registry/index.json")
|
||||||
|
val index = Json.decodeFromString<RegistryIndex>(str)
|
||||||
|
println(index)
|
||||||
|
}
|
||||||
5
pom.xml
5
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>work.slhaf.partner</groupId>
|
<groupId>work.slhaf.partner</groupId>
|
||||||
<artifactId>partner</artifactId>
|
<artifactId>partner</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
<!-- 推荐仓库默认不跳测试;本地需要时再 -DskipTests=true -->
|
<!-- 推荐仓库默认不跳测试;本地需要时再 -DskipTests=true -->
|
||||||
<skipTests>false</skipTests>
|
<skipTests>false</skipTests>
|
||||||
|
|
||||||
|
<partner.runtime.version>0.5.0</partner.runtime.version>
|
||||||
|
<partner.interaction-api.version>1.0.0</partner.interaction-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
"ref": "buildable/0.5.0"
|
"ref": "buildable/0.5.0"
|
||||||
},
|
},
|
||||||
"latestRelease": {
|
"latestRelease": {
|
||||||
"url": "https://github.com/slhaf/Partner/releases/download/rel-v0.5.0/partner-core-0.5.0.jar",
|
"url": "https://github.com/slhaf/Partner/releases/download/release-core%2F0.5.0/partner-core-0.5.0.jar",
|
||||||
"version": "0.5.0"
|
"version": "0.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"externalModules": [
|
"externalModules": [
|
||||||
{
|
{
|
||||||
"name": "OneBot Adapter",
|
"name": "OneBot Adapter",
|
||||||
"version": "0.5.0",
|
"version": "1.0.0",
|
||||||
"withGateway": true,
|
"withGateway": true,
|
||||||
"registryRef": "modules/onebot-adapter.json"
|
"registryRef": "modules/onebot-adapter.json"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "onebot_channel",
|
"id": "onebot_channel",
|
||||||
"name": "OneBot Adapter",
|
"name": "OneBot Adapter",
|
||||||
"version": "0.5.0",
|
"version": "1.0.0",
|
||||||
"withGateway": true,
|
"withGateway": true,
|
||||||
"description": "OneBot v11 reverse WebSocket gateway adapter for Partner. It accepts reverse WebSocket connections from a OneBot implementation and converts private message events into Partner input events.",
|
"description": "OneBot v11 reverse WebSocket gateway adapter for Partner. It accepts reverse WebSocket connections from a OneBot implementation and converts private message events into Partner input events.",
|
||||||
"source": {
|
"source": {
|
||||||
|
|||||||
Reference in New Issue
Block a user