chore(build): 更新发布配置并添加MIT许可证 #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [master] | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'Version bump type (patch / minor / major)' | |
| required: false | |
| default: patch | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x ./gradlew | |
| - name: Resolve next version | |
| id: ver | |
| run: | | |
| BUMP="${{ github.event.inputs.version_bump || 'patch' }}" | |
| LATEST=$(git tag --sort=-v:refname | head -n1) | |
| if [ -z "$LATEST" ]; then | |
| TAG="v0.1.0" | |
| else | |
| MAJOR=$(echo "$LATEST" | sed 's/v\([0-9]*\).*/\1/') | |
| MINOR=$(echo "$LATEST" | sed 's/v[0-9]*\.\([0-9]*\).*/\1/') | |
| PATCH=$(echo "$LATEST" | sed 's/v[0-9]*\.[0-9]*\.\([0-9]*\)/\1/') | |
| case "$BUMP" in | |
| major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | |
| minor) MINOR=$((MINOR + 1)); PATCH=0 ;; | |
| *) PATCH=$((PATCH + 1)) ;; | |
| esac | |
| TAG="v${MAJOR}.${MINOR}.${PATCH}" | |
| fi | |
| VERSION="${TAG#v}" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Next release: $TAG" | |
| - name: Build Vicky.jar | |
| run: ./gradlew shadowJar -Pversion=${{ steps.ver.outputs.version }} --no-daemon --stacktrace | |
| - name: Stage release artifact | |
| run: | | |
| mkdir -p release | |
| cp build/libs/Vicky-${{ steps.ver.outputs.version }}.jar "release/Vicky-${{ steps.ver.outputs.version }}.jar" | |
| - name: Create tag and GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.ver.outputs.tag }} | |
| name: ${{ steps.ver.outputs.tag }} | |
| generate_release_notes: true | |
| files: | | |
| release/Vicky-${{ steps.ver.outputs.version }}.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to Maven Central | |
| run: ./gradlew publishAndReleaseToMavenCentral -Pversion=${{ steps.ver.outputs.version }} --no-daemon --stacktrace | |
| env: | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} |