Skip to content

Commit

Permalink
chore: add push to maven workflow config (#40)
Browse files Browse the repository at this point in the history
### What this  PR does?
添加发版时自动将工件推送到 Maven 的 workflow 配置

```release-note
None
```
  • Loading branch information
guqing authored Dec 5, 2024
1 parent cff7c7e commit bffc7e1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/push-to-maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish plugin API module to Maven

on:
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Extract version from GitHub tag
id: extract_version
run: |
tag_name=${{ github.event.release.tag_name }}
VERSION=${tag_name#v}
echo "Extracted Version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build with Gradle
run: ./gradlew clean build -Pversion=${{ env.VERSION }}

- name: Push to Maven
env:
OSSR_USERNAME: ${{ secrets.MAVEN_USERNAME }}
OSSR_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: ./gradlew :api:publish -Pversion=${{ env.VERSION }}
1 change: 0 additions & 1 deletion api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact tasks.sourcesJar

artifactId = 'api'
version = project.hasProperty('version') ? project.property('version') : 'unspecified'
Expand Down

0 comments on commit bffc7e1

Please sign in to comment.