From 1eff1e5853455983f0fad4105b637ca127879f8f Mon Sep 17 00:00:00 2001 From: ryoii Date: Fri, 10 Feb 2023 19:54:29 +0800 Subject: [PATCH] Add spi publish --- .github/workflows/publish.yml | 30 ++++++++++++++--------------- mirai-api-http-spi/build.gradle.kts | 26 +++++++++++++++++++++++++ mirai-api-http/build.gradle.kts | 2 +- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9e5e4610..c3774044 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,14 +29,24 @@ jobs: - name: Build with Gradle run: ./gradlew buildCiJar + - name: Build SPI + run: ./gradlew buildSpi + - name: Publish to Maven Central run: ./gradlew mirai-api-http:publish --info --scan env: PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }} + - name: Publish to SPI Maven Central + run: ./gradlew mirai-api-http-spi:publish --info --scan + env: + PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }} + - name: Get Tag id: tag - uses: dawidd6/action-get-tag@v1 + run: | + tag=$(echo ${{ github.ref }} | cut -dv -f2) + echo "tag=$tag" >> $GITHUB_OUTPUT - name: Generate Line Temp File run: "cat CHANGELOG.md | grep -n '## \\\\' | cut -d: -f1 | head -n 2 >> line.tmp" @@ -46,25 +56,15 @@ jobs: - name: Create Release id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v1 with: tag_name: ${{ github.ref }} - release_name: mirai-api-http-${{ steps.tag.outputs.tag }} + name: mirai-api-http-${{ steps.tag.outputs.tag }} body_path: release.log draft: false prerelease: false - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./mirai-api-http/build/ci/mirai-api-http.jar - asset_name: mirai-api-http-${{ steps.tag.outputs.tag }}.mirai2.jar - asset_content_type: application/zip + files: | + ./mirai-api-http/build/ci/mirai-api-http-${{ steps.tag.outputs.tag }}.mirai2.jar - name: Clone Mirai-Repo uses: actions/checkout@v3 diff --git a/mirai-api-http-spi/build.gradle.kts b/mirai-api-http-spi/build.gradle.kts index 2e7656fa..09f7aed6 100644 --- a/mirai-api-http-spi/build.gradle.kts +++ b/mirai-api-http-spi/build.gradle.kts @@ -5,6 +5,9 @@ plugins { id("me.him188.maven-central-publish") } +val httpVersion: String by rootProject.extra +project.version = httpVersion + dependencies { } @@ -20,4 +23,27 @@ tasks { compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } +} + +tasks.register("buildSpi", Jar::class) { + dependsOn("build") + doLast { + val jarTask = tasks.getByName("jar", Jar::class) + val buildPluginFile = jarTask.archiveFile.get().asFile + project.buildDir.resolve("ci").also { + it.mkdirs() + }.resolve("mirai-api-http-spi-${{ project.version }}.jar").let { + buildPluginFile.copyTo(it, true) + } + } +} + +mavenCentralPublish { + workingDir = rootProject.buildDir.resolve("pub").apply { mkdirs() } + githubProject("project-mirai", "mirai-api-http-spi") + licenseFromGitHubProject("licenseAgplv3", "master") + developer("Mamoe Technologies") + publication { + artifact(tasks.getByName("buildSpi")) + } } \ No newline at end of file diff --git a/mirai-api-http/build.gradle.kts b/mirai-api-http/build.gradle.kts index 1d5957c2..0e0d3ada 100644 --- a/mirai-api-http/build.gradle.kts +++ b/mirai-api-http/build.gradle.kts @@ -45,7 +45,7 @@ tasks.register("buildCiJar", Jar::class) { val buildPluginFile = buildPluginTask.archiveFile.get().asFile project.buildDir.resolve("ci").also { it.mkdirs() - }.resolve("mirai-api-http.jar").let { + }.resolve("mirai-api-http-${{ project.version }}.mirai2.jar").let { buildPluginFile.copyTo(it, true) } }