diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ea23ab2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,103 @@ +name: Build and Deploy + +on: + push: + branches: + - develop + release: + types: [published] + workflow_dispatch: + inputs: + deployment_id: + description: Central deployment ID to publish + required: true + type: string + +jobs: + build: + if: github.event_name != 'workflow_dispatch' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 8 + + - name: Check Maven module version + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + if [[ $GITHUB_REF == 'refs/heads/develop' && $VERSION != *"-SNAPSHOT"* ]]; then + echo "Refusing to deploy release version $VERSION from develop" + exit 1 + fi + + - name: Import GPG private key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + + - name: Build with Maven + run: mvn clean install + + - name: Deploy to Sonatype Central + run: mvn -P release clean deploy --settings settings.xml -DskipTests + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + + publish-deployment: + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + + steps: + - name: Publish validated Central deployment + env: + DEPLOYMENT_ID: ${{ inputs.deployment_id }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + run: | + set -euo pipefail + + if [[ ! "$DEPLOYMENT_ID" =~ ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$ ]]; then + echo "Invalid Central deployment ID" + exit 1 + fi + + AUTH_TOKEN=$(printf '%s:%s' "$MAVEN_USERNAME" "$MAVEN_PASSWORD" | base64 | tr -d '\n') + AUTH_HEADER="Authorization: Bearer $AUTH_TOKEN" + CENTRAL_API="https://central.sonatype.com/api/v1/publisher" + + curl --fail-with-body --silent --show-error \ + --request POST \ + --header "$AUTH_HEADER" \ + "$CENTRAL_API/deployment/$DEPLOYMENT_ID" + + for attempt in {1..60}; do + RESPONSE=$(curl --fail-with-body --silent --show-error \ + --request POST \ + --header "$AUTH_HEADER" \ + "$CENTRAL_API/status?id=$DEPLOYMENT_ID") + STATE=$(jq -r '.deploymentState' <<<"$RESPONSE") + echo "Central deployment state: $STATE" + + case "$STATE" in + PUBLISHED) + exit 0 + ;; + FAILED) + jq '.errors // empty' <<<"$RESPONSE" + exit 1 + ;; + esac + + sleep 10 + done + + echo "Timed out waiting for Central deployment to publish" + exit 1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d697110 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 DingTalk Real AI Team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pom.xml b/pom.xml index a695913..4f89230 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,28 @@ DingTalk Channel SDK (Java) — runtime-agnostic conversation access layer for AI agents https://github.com/DingTalk-Real-AI/dingtalk-channel-sdk-java + + + The MIT License + https://opensource.org/license/mit + repo + + + + + https://github.com/DingTalk-Real-AI/dingtalk-channel-sdk-java + scm:git:https://github.com/DingTalk-Real-AI/dingtalk-channel-sdk-java.git + scm:git:https://github.com/DingTalk-Real-AI/dingtalk-channel-sdk-java.git + HEAD + + + + + dingtalk + https://open.dingtalk.com + + + 8 8 @@ -52,4 +74,75 @@ + + + + release + + + + org.sonatype.central + central-publishing-maven-plugin + 0.9.0 + true + + sonatype + true + published + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.4 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + none + true + + + + attach-javadocs + + jar + + + + + + + + diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..f4d5f69 --- /dev/null +++ b/settings.xml @@ -0,0 +1,11 @@ + + + + sonatype + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + +