diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..c1b4d01 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,17 @@ +name: CD + +on: + release: + types: + - published + +jobs: + cd: + uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v3 + secrets: + halo-pat: ${{ secrets.HALO_PAT }} + permissions: + contents: write + with: + skip-node-setup: true + app-id: app-oPNFQ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..f98a3c3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,15 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + ci: + uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v3 + with: + skip-node-setup: true diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml deleted file mode 100644 index b4f70ed..0000000 --- a/.github/workflows/workflow.yaml +++ /dev/null @@ -1,104 +0,0 @@ -name: Build Plugin JAR File - -on: - push: - branches: [ main ] - release: - types: - - created - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - distribution: "temurin" - cache: "gradle" - java-version: 17 - - name: Build with Gradle - run: | - # Set the version with tag name when releasing - version=${{ github.event.release.tag_name }} - version=${version#v} - sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties - ./gradlew clean build -x test - - name: Archive plugin-live2d jar - uses: actions/upload-artifact@v2 - with: - name: plugin-live2d - path: | - build/libs/*.jar - retention-days: 1 - - github-release: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'release' - steps: - - name: Download plugin-live2d jar - uses: actions/download-artifact@v2 - with: - name: plugin-live2d - path: build/libs - - name: Get Name of Artifact - id: get_artifact - run: | - ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1) - ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME}) - echo "Artifact pathname: ${ARTIFACT_PATHNAME}" - echo "Artifact name: ${ARTIFACT_NAME}" - echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV - echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV - echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV - - name: Upload a Release Asset - uses: actions/github-script@v2 - if: github.event_name == 'release' - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - console.log('environment', process.versions); - - const fs = require('fs').promises; - - const { repo: { owner, repo }, sha } = context; - console.log({ owner, repo, sha }); - - const releaseId = process.env.RELEASE_ID - const artifactPathName = process.env.ARTIFACT_PATHNAME - const artifactName = process.env.ARTIFACT_NAME - console.log('Releasing', releaseId, artifactPathName, artifactName) - - await github.repos.uploadReleaseAsset({ - owner, repo, - release_id: releaseId, - name: artifactName, - data: await fs.readFile(artifactPathName) - }); - - app-store-release: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'release' - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Download plugin-live2d jar - uses: actions/download-artifact@v2 - with: - name: plugin-live2d - path: build/libs - - name: Sync to Halo App Store - uses: halo-sigs/app-store-release-action@main - with: - github-token: ${{secrets.GITHUB_TOKEN}} - app-id: ${{secrets.APP_ID}} - release-id: ${{ github.event.release.id }} - assets-dir: "build/libs" - halo-username: ${{ secrets.HALO_USERNAME }} - halo-password: ${{ secrets.HALO_PASSWORD }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index a67815b..b30a973 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "io.freefair.lombok" version "8.0.1" - id "run.halo.plugin.devtools" version "0.0.7" + id "run.halo.plugin.devtools" version "0.5.0" id 'java' } @@ -9,7 +9,9 @@ sourceCompatibility = JavaVersion.VERSION_17 repositories { mavenCentral() - maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' } + maven { url 'https://s01.oss.sonatype.org/content/repositories/releases' } + maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } + maven { url 'https://repo.spring.io/milestone' } } configurations.runtimeClasspath { @@ -30,6 +32,10 @@ test { useJUnitPlatform() } +tasks.withType(JavaCompile).configureEach { + options.encoding = "UTF-8" +} + halo { version = '2.11.2' port = 8092 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927..ccebba7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e1bef7e..3c44eb1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..79a61d4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle index 9cccbe8..96924b7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,5 @@ pluginManagement { repositories { - maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' } - maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } - maven { url 'https://maven.aliyun.com/repository/spring-plugin' } - maven { url 'https://repo.spring.io/milestone' } gradlePluginPortal() } } diff --git a/src/main/java/run/halo/live2d/Live2dPlugin.java b/src/main/java/run/halo/live2d/Live2dPlugin.java index 3bd1324..ac06d3f 100644 --- a/src/main/java/run/halo/live2d/Live2dPlugin.java +++ b/src/main/java/run/halo/live2d/Live2dPlugin.java @@ -1,8 +1,8 @@ package run.halo.live2d; -import org.pf4j.PluginWrapper; import org.springframework.stereotype.Component; import run.halo.app.plugin.BasePlugin; +import run.halo.app.plugin.PluginContext; /** * @author LIlGG @@ -11,7 +11,7 @@ @Component public class Live2dPlugin extends BasePlugin { - public Live2dPlugin(PluginWrapper wrapper) { - super(wrapper); + public Live2dPlugin(PluginContext context) { + super(context); } } diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml index 4c018f2..0a2a9f0 100644 --- a/src/main/resources/plugin.yaml +++ b/src/main/resources/plugin.yaml @@ -2,17 +2,22 @@ apiVersion: plugin.halo.run/v1alpha1 kind: Plugin metadata: name: PluginLive2d + annotations: + "store.halo.run/app-id": "app-oPNFQ" spec: enabled: true - requires: ">=2.4.0" + requires: ">=2.10.0" author: name: LIlGG website: https://lixingyong.com logo: logo.gif - settingName: plugin-live2d-settings - configMapName: plugin-live2d-configs - homepage: https://github.com/LIlGG/plugin-live2d + repo: https://github.com/LIlGG/plugin-live2d + homepage: https://www.halo.run/store/apps/app-oPNFQ + issues: https://github.com/LIlGG/plugin-live2d/issues displayName: "live2d 看板娘" description: "为主题增加一个萌萌哒的看板娘吧!ʕ̯•͡ˑ͓•̯᷅ʔ" + settingName: plugin-live2d-settings + configMapName: plugin-live2d-configs license: - name: "MIT" + url: "https://github.com/LIlGG/plugin-live2d/blob/main/LICENSE"