diff --git a/.github/workflows/maven-build.yml b/.github/workflows/build.yml
similarity index 70%
rename from .github/workflows/maven-build.yml
rename to .github/workflows/build.yml
index 9daa5e9..dd12ddf 100644
--- a/.github/workflows/maven-build.yml
+++ b/.github/workflows/build.yml
@@ -6,7 +6,7 @@
# separate terms of service, privacy policy, and support
# documentation.
-name: Maven Build
+name: Build
on:
push:
@@ -29,19 +29,22 @@ on:
- '*.adoc'
- '*.txt'
- '.all-contributorsrc'
-
jobs:
- build:
- runs-on: ubuntu-latest
+ release-name-check:
+ uses: ./.github/workflows/pre-release.yml
+ build:
+ runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 8
- uses: actions/setup-java@v4
- with:
- java-version: '8'
- distribution: 'temurin'
- cache: maven
- - name: Build with Maven
- run: mvn -B clean package --file pom.xml
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Set up JDK 8
+ uses: actions/setup-java@v4
+ with:
+ java-version: '8'
+ distribution: 'temurin'
+ cache: maven
+ - name: Build with Maven
+ run: mvn -B clean package
diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
deleted file mode 100644
index 0f11ecd..0000000
--- a/.github/workflows/maven-publish.yml
+++ /dev/null
@@ -1,105 +0,0 @@
-# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
-# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
-
-name: Maven Release
-
-on:
- pull_request:
- types: [closed]
-
-jobs:
- release:
- runs-on: ubuntu-latest
- name: release
- permissions:
- contents: read
- packages: write
-
- steps:
- - uses: actions/checkout@v4
-
- - name: Checkout Repository
- uses: actions/checkout@v4
-
- - name: Read Pull Request Title
- id: pr-title
- run: |
- title=$(cat $GITHUB_EVENT_PATH | jq -r '.pull_request.title')
- echo "Pull Request Title: $title"
- echo "pr_title=$title" >> $GITHUB_OUTPUT
-
- - name: Extract info from pom.xml
- id: extract-info
- run: |
- groupId=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout)
- artifactId=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
- version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- echo "Pom GroupId: $groupId"
- echo "Pom ArtifactId: $artifactId"
- echo "Pom Version: $version"
- echo "version=$version" >> $GITHUB_OUTPUT
- echo "artifactId=$artifactId" >> $GITHUB_OUTPUT
- echo "groupId=$groupId" >> $GITHUB_OUTPUT
-
- - name: Check Maven Central Repository
- id: check-maven-central
- run: |
- version="${{ steps.extract-info.outputs.version }}"
- groupId="${{ steps.extract-info.outputs.groupId }}"
- artifactId="${{ steps.extract-info.outputs.artifactId }}"
- URL=https://repo1.maven.org/maven2/$(echo $groupId | tr . /)/${artifactId}/maven-metadata.xml
- echo $URL
-
- # 检查 URL 是否存在
- RESPONSE_CODE=$(curl -sSL -o /dev/null -w "%{http_code}" "$URL")
- echo $RESPONSE_CODE
-
- if [ "$RESPONSE_CODE" == "200" ]; then
- # 文件存在,继续检查版本
- RESPONSE=$(curl -sSL "$URL")
- if echo "$RESPONSE" | grep "$version" > /dev/null; then
- echo "Version $version exists in Maven Central."
- exit 1
- else
- echo "Version $version does not exist in Maven Central."
- fi
- elif [ "$RESPONSE_CODE" == "404" ]; then
- echo "The metadata file for $groupId:$artifactId does not exist in Maven Central."
- else
- echo "An unexpected error occurred while checking the metadata file for $groupId:$artifactId."
- fi
-
- - name: Validate Pull Request Title
- run: | # 读取 Pull Request 标题和版本号
- title="${{ steps.pr-title.outputs.pr_title }}"
- version="${{ steps.extract-info.outputs.version }}"
- echo "Pull Request Title: $title"
- echo "Version: $version"
- # 转换为小写并进行条件判断
- if [[ "${title,,}" =~ ^release-$version$ ]]; then
- echo "Pull Request title is valid."
- else
- echo "Pull Request title must be in the format 'release-$version'."
- exit 1
- fi
-
- - name: Set up Maven Central Repository
- uses: actions/setup-java@v4
- with: # running setup-java again overwrites the settings.xml
- java-version: '8'
- distribution: 'temurin'
- server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
- server-username: MAVEN_USERNAME # env variable for username in deploy
- server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
- gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
- gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
-
- - name: Publish to Apache Maven Central
- run: mvn -B deploy
- env:
- MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
- MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
- MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
-
-
-
diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml
new file mode 100644
index 0000000..e11b591
--- /dev/null
+++ b/.github/workflows/pre-release.yml
@@ -0,0 +1,109 @@
+name: Check PR Name Enable Release
+
+on:
+ workflow_call:
+ outputs:
+ release_name_check:
+ value: ${{ jobs.pre-release-check.outputs.release_name_check }}
+
+
+jobs:
+ pre-release-check:
+ runs-on: ubuntu-latest
+ name: check pull request is release
+ outputs:
+ release_name_check: ${{ steps.check.outputs.release_name_check }}
+ steps:
+ - id: check-release-name
+ name: Check Release Name
+ run: |
+ pr_title=$(cat $GITHUB_EVENT_PATH | jq -r '.pull_request.title')
+ echo "PR Title: $pr_title"
+
+ # 转换为小写
+ pr_title_lower=$(echo "$pr_title" | tr '[:upper:]' '[:lower:]')
+ echo "PR Title (Lowercase): $pr_title_lower"
+
+ # 判断是否以 'release-' 开头
+ if [[ $pr_title_lower == release-* ]]; then
+ echo "Title starts with 'release-' (case-insensitive)"
+ need_release=true
+ else
+ echo "Title does not start with 'release-' (case-insensitive)"
+ need_release=false
+ fi
+ echo "need_release=$need_release" >> $GITHUB_OUTPUT
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Read Pull Request Info
+ id: pr-info
+ if: ${{ steps.check-release-name.outputs.need_release == 'true' }}
+ run: |
+ title=$(cat $GITHUB_EVENT_PATH | jq -r '.pull_request.title')
+ echo "Pull Request Title: $title"
+ echo "title=$title" >> $GITHUB_OUTPUT
+ body=$(cat $GITHUB_EVENT_PATH | jq -r '.pull_request.body')
+ echo "PR Body: $body"
+ echo "body<> "$GITHUB_OUTPUT"
+
+ - name: Extract info from pom.xml
+ id: extract-info
+ if: ${{ steps.check-release-name.outputs.need_release == 'true' }}
+ run: |
+ groupId=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout)
+ artifactId=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
+ version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
+ echo "Pom GroupId: $groupId"
+ echo "Pom ArtifactId: $artifactId"
+ echo "Pom Version: $version"
+ echo "version=$version" >> $GITHUB_OUTPUT
+ echo "artifactId=$artifactId" >> $GITHUB_OUTPUT
+ echo "groupId=$groupId" >> $GITHUB_OUTPUT
+
+ - name: Check Maven Central Repository & Validate Pull Request Title
+ id: check
+ if: ${{ steps.check-release-name.outputs.need_release == 'true' }}
+ run: |
+ version="${{ steps.extract-info.outputs.version }}"
+ groupId="${{ steps.extract-info.outputs.groupId }}"
+ artifactId="${{ steps.extract-info.outputs.artifactId }}"
+ URL=https://repo1.maven.org/maven2/$(echo $groupId | tr . /)/${artifactId}/maven-metadata.xml
+ echo $URL
+
+ # 检查 URL 是否存在
+ RESPONSE_CODE=$(curl -sSL -o /dev/null -w "%{http_code}" "$URL")
+ echo $RESPONSE_CODE
+
+ if [ "$RESPONSE_CODE" == "200" ]; then
+ # 文件存在,继续检查版本
+ RESPONSE=$(curl -sSL "$URL")
+ if echo "$RESPONSE" | grep "$version" > /dev/null; then
+ echo "Version $version exists in Maven Central."
+ echo "release_name_check=false" >> $GITHUB_OUTPUT
+ else
+ echo "Version $version does not exist in Maven Central."
+ echo "release_name_check=true" >> $GITHUB_OUTPUT
+ fi
+ elif [ "$RESPONSE_CODE" == "404" ]; then
+ echo "The metadata file for $groupId:$artifactId does not exist in Maven Central."
+ echo "release_name_check=true" >> $GITHUB_OUTPUT
+ else
+ echo "An unexpected error occurred while checking the metadata file for $groupId:$artifactId."
+ echo "release_name_check=true" >> $GITHUB_OUTPUT
+ fi
+
+ # 检查 PR 标题
+ title="${{ steps.pr-info.outputs.title }}"
+ version="${{ steps.extract-info.outputs.version }}"
+ echo "Pull Request Title: $title"
+ echo "Version: $version"
+ # 转换为小写并进行条件判断
+ if [[ "${title,,}" =~ ^release-$version$ ]]; then
+ echo "Pull Request title is valid."
+ echo "release_name_check=true" >> $GITHUB_OUTPUT
+ else
+ echo "Pull Request title must be in the format 'release-$version'."
+ echo "release_name_check=false" >> $GITHUB_OUTPUT
+ fi
+
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..667c432
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,83 @@
+# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
+# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
+
+name: Release
+
+on:
+ pull_request:
+ types: [closed]
+
+jobs:
+
+ release-name-check:
+ uses: ./.github/workflows/pre-release.yml
+
+ publish:
+ needs: [release-name-check]
+ runs-on: ubuntu-latest
+ if: ${{ needs.release-name-check.outputs.release_name_check == 'true' }}
+ name: publish project
+ permissions:
+ contents: write
+ packages: write
+
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Get Release Parameters
+ id: extract-info
+ run: |
+ groupId=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout)
+ artifactId=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
+ version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
+ body=$(cat $GITHUB_EVENT_PATH | jq -r '.pull_request.body')
+ echo "PR Body: $body"
+ echo "body<> "$GITHUB_OUTPUT"
+ echo "Pom GroupId: $groupId"
+ echo "Pom ArtifactId: $artifactId"
+ echo "Pom Version: $version"
+ echo "version=$version" >> $GITHUB_OUTPUT
+ echo "artifactId=$artifactId" >> $GITHUB_OUTPUT
+ echo "groupId=$groupId" >> $GITHUB_OUTPUT
+
+ - name: Set up Maven Central Repository
+ uses: actions/setup-java@v4
+ with: # running setup-java again overwrites the settings.xml
+ java-version: '8'
+ distribution: 'temurin'
+ server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
+ server-username: MAVEN_USERNAME # env variable for username in deploy
+ server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
+ gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
+ gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
+
+ - name: Publish to Apache Maven Central
+ run: mvn -B deploy
+ env:
+ MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
+ MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
+ MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
+
+ - name: Create Github Tag
+ uses: negz/create-tag@v1
+ with:
+ version: v${{ steps.extract-info.outputs.version }}
+ message: ${{ steps.extract-info.outputs.body }}
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Create Github Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
+ with:
+ tag_name: v${{ steps.extract-info.outputs.version }}
+ release_name: v${{ steps.extract-info.outputs.version }}
+ body: ${{ steps.extract-info.outputs.body }}
+ draft: false
+ prerelease: false
+
+
+
+
diff --git a/pom.xml b/pom.xml
index af5440e..31eedd9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,13 +6,13 @@
io.github.easyretrofit
parent
- 1.0.0
+ 1.1.0
4.0.0
The function of core is to generate retrofit instances based on the DI framework and manage retrofit resource context
core
- 1.0.2
+ 1.1.0
jar
https://github.com/easyretrofit/${project.artifactId}