doc/ARCHITECTURE.md
┌─────────────────────────────────────────────────────────────┐
│ Git Tag 触发 │
│ git tag v11.3.0 │
│ git push origin v11.3.0 │
└─────────────────┬───────────────────────────┬───────────────┘
│ │
┌─────────────▼─────────────┐ ┌─────────▼──────────────┐
│ release.yml (已有) │ │ publish-maven-central │
│ │ │ .yml (新增) │
│ GitHub Packages 发布 │ │ Maven Central 发布 │
└─────────────┬─────────────┘ └──────────┬─────────────┘
│ │
┌─────────────▼─────────────┐ ┌─────────▼──────────────┐
│ publish.gradle │ │ maven-central-publish │
│ │ │ .gradle │
│ GROUP: com.shuyu │ │ GROUP: io.github. │
│ │ │ carguo │
│ Publication: release │ │ Publication: │
│ │ │ mavenCentral │
└─────────────┬─────────────┘ └──────────┬─────────────┘
│ │
▼ ▼
┌─────────────────────────┐ ┌──────────────────────────┐
│ GitHub Packages │ │ Maven Central │
│ │ │ │
│ com.shuyu: │ │ io.github.carguo: │
│ gsyvideoplayer-java: │ │ gsyvideoplayer-java: │
│ 11.3.0 │ │ 11.3.0 │
└─────────────────────────┘ └──────────────────────────┘
GSYVideoPlayer/
├── gradle.properties
│ ├── PROJ_GROUP=com.shuyu ← GitHub Packages
│ └── PROJ_GROUP_MAVEN_CENTRAL=io.github.carguo ← Maven Central
│
├── gradle/
│ ├── publish.gradle ← GitHub Packages 配置
│ │ └── publication "release"
│ │ └── group = PROJ_GROUP (com.shuyu)
│ │
│ └── maven-central-publish.gradle ← Maven Central 配置
│ └── publication "mavenCentral"
│ └── group = PROJ_GROUP_MAVEN_CENTRAL (io.github.carguo)
│
├── gsyVideoPlayer-java/
│ ├── build.gradle
│ │ ├── apply from: "$rootDir/gradle/publish.gradle"
│ │ ├── apply from: "$rootDir/gradle/maven-central-publish.gradle"
│ │ └── publishing { repositories { maven { ... } } }
│ │
│ └── gradle.properties
│ └── PROJ_ARTIFACTID=gsyvideoplayer-java
│
└── .github/workflows/
├── release.yml ← GitHub Packages workflow
│ └── ./gradlew publish
│
└── publish-maven-central.yml ← Maven Central workflow
└── ./gradlew publishToSonatype closeAndRelease...
为了避免冲突,两个发布使用不同的 publication 名称:
| 配置文件 | Publication 名称 | 用途 |
|---|---|---|
publish.gradle | release | GitHub Packages |
maven-central-publish.gradle | mavenCentral | Maven Central |
这样在 Gradle tasks 中可以明确区分:
# GitHub Packages
./gradlew publishReleasePublicationToGsyvideoplayerRepository
# Maven Central
./gradlew publishMavenCentralPublicationToSonatypeRepository
repositories {
maven {
url = "https://maven.pkg.github.com/CarGuo/GSYVideoPlayer"
credentials {
username = "your-github-username"
password = "your-github-token"
}
}
}
dependencies {
implementation 'com.shuyu:gsyvideoplayer-java:11.3.0'
}
repositories {
mavenCentral() // 不需要额外配置!
}
dependencies {
implementation 'io.github.carguo:gsyvideoplayer-java:11.3.0'
}
PROJ_GROUP_MAVEN_CENTRAL 实现对于用户:
com.shuyu (无需修改)io.github.carguo (不需要 GitHub token)在 README 中提供两种依赖方式,并说明区别。