Skip to content

Commit 2f741a3

Browse files
committed
set upload ci
1 parent 0d06ae0 commit 2f741a3

File tree

4 files changed

+250
-116
lines changed

4 files changed

+250
-116
lines changed

.github/workflows/upload.yml

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
1-
21
name: Android CI
32

43
on:
5-
push:
6-
pull_request:
4+
push:
5+
pull_request:
76

87
jobs:
9-
build:
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- uses: actions/checkout@v2
14-
- name: Set up JDK 1.8
15-
uses: actions/setup-java@v1
16-
with:
17-
java-version: '1.8'
18-
- name: Publish to Sonatype
19-
env:
20-
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
21-
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
22-
run: ./gradlew clean build uploadArchives -PNEXUS_USERNAME="${NEXUS_USERNAME}" -PNEXUS_PASSWORD="${NEXUS_PASSWORD}"
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 1.8
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: '1.8'
17+
18+
# Gradle 缓存配置
19+
- name: Cache Gradle packages
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.gradle/caches
23+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
24+
restore-keys: ${{ runner.os }}-gradle
25+
26+
# 给 gradlew 文件授权
27+
- name: Grant execute permission for gradlew
28+
run: chmod +x gradlew
29+
30+
# 构建项目
31+
- name: Build with Gradle
32+
run: ./gradlew clean build
33+
34+
# 将秘钥解码后将文件放置 ~/.gradle/secring.gpg
35+
- name: Decode
36+
run: |
37+
echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64
38+
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
39+
40+
- name: Publish to Sonatype
41+
env:
42+
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
43+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
44+
run: ./gradlew uploadArchives -PNEXUS_USERNAME="${NEXUS_USERNAME}" -PNEXUS_PASSWORD="${NEXUS_PASSWORD}" -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg)

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# Simple Slider
1+
Simple Slider
2+
=====
3+
4+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.cpacm.simpleslider/simpleslider/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.cpacm.simpleslider/simpleslider)
5+
6+
## Intro
27

38
I wrote this library just because I want a lightweight slider.
49
>Use your own imageloader;

script/publishMaven.gradle

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/*
2+
* Copyright 2013 Chris Banes
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
* Based on: https://github.com/mcxiaoke/gradle-mvn-push/blob/master/gradle-mvn-push.gradle.
18+
*
19+
* To install in a local maven repo:
20+
* 1. In the project you want to test (not Glide), add mavenLocal() to the repositories list.
21+
* 2. In Glide, run: ./gradlew uploadArchives -PLOCAL
22+
*
23+
* For faster runs add: -x check when building Glide.
24+
*/
25+
26+
apply plugin: 'maven-publish'
27+
apply plugin: 'signing'
28+
29+
version = VERSION_NAME
30+
group = GROUP
31+
32+
static def localMavenRepo() {
33+
'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
34+
}
35+
36+
@SuppressWarnings("GrMethodMayBeStatic")
37+
def isReleaseBuild() {
38+
return !VERSION_NAME.contains("SNAPSHOT")
39+
}
40+
41+
def getReleaseRepositoryUrl() {
42+
return hasProperty('LOCAL') ? localMavenRepo()
43+
: hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
44+
//: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
45+
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
46+
}
47+
48+
def getSnapshotRepositoryUrl() {
49+
return hasProperty('LOCAL') ? localMavenRepo()
50+
: hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
51+
//: 'https://oss.sonatype.org/content/repositories/snapshots/'
52+
: 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
53+
}
54+
55+
def getRepositoryUsername() {
56+
return hasProperty('USERNAME') ? USERNAME : (hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : '')
57+
}
58+
59+
def getRepositoryPassword() {
60+
return hasProperty('PASSWORD') ? PASSWORD : (hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : '')
61+
}
62+
63+
def configurePom(pom) {
64+
pom.name = POM_NAME
65+
pom.packaging = POM_PACKAGING
66+
pom.description = POM_DESCRIPTION
67+
pom.url = POM_URL
68+
69+
pom.scm {
70+
url = POM_SCM_URL
71+
connection = POM_SCM_CONNECTION
72+
developerConnection = POM_SCM_DEV_CONNECTION
73+
}
74+
75+
pom.licenses {
76+
license {
77+
name = POM_LICENCE_NAME
78+
url = POM_LICENCE_URL
79+
distribution = POM_LICENCE_DIST
80+
}
81+
}
82+
83+
pom.developers {
84+
developer {
85+
id = POM_DEVELOPER_ID
86+
name = POM_DEVELOPER_NAME
87+
}
88+
}
89+
}
90+
91+
afterEvaluate { project ->
92+
publishing {
93+
repositories {
94+
maven {
95+
def releasesRepoUrl = getReleaseRepositoryUrl()
96+
def snapshotsRepoUrl = getSnapshotRepositoryUrl()
97+
url = isReleaseBuild() ? releasesRepoUrl : snapshotsRepoUrl
98+
99+
credentials(PasswordCredentials) {
100+
username = getRepositoryUsername()
101+
password = getRepositoryPassword()
102+
}
103+
}
104+
}
105+
}
106+
107+
if (project.getPlugins().hasPlugin('com.android.application') ||
108+
project.getPlugins().hasPlugin('com.android.library')) {
109+
110+
task androidJavadocs(type: Javadoc) {
111+
source = android.sourceSets.main.java.source
112+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
113+
excludes = ['**/*.kt']
114+
}
115+
116+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
117+
classifier = 'javadoc'
118+
from androidJavadocs.destinationDir
119+
}
120+
121+
task androidSourcesJar(type: Jar) {
122+
classifier = 'sources'
123+
from android.sourceSets.main.java.source
124+
}
125+
}
126+
127+
if (JavaVersion.current().isJava8Compatible()) {
128+
allprojects {
129+
tasks.withType(Javadoc) {
130+
options.addStringOption('Xdoclint:none', '-quiet')
131+
}
132+
}
133+
}
134+
135+
if (JavaVersion.current().isJava9Compatible()) {
136+
allprojects {
137+
tasks.withType(Javadoc) {
138+
options.addBooleanOption('html5', true)
139+
}
140+
}
141+
}
142+
143+
artifacts {
144+
if (project.getPlugins().hasPlugin('com.android.application') ||
145+
project.getPlugins().hasPlugin('com.android.library')) {
146+
archives androidSourcesJar
147+
archives androidJavadocsJar
148+
}
149+
}
150+
151+
android.libraryVariants.all { variant ->
152+
tasks.androidJavadocs.doFirst {
153+
classpath += files(variant.javaCompileProvider.get().classpath.files.join(File.pathSeparator))
154+
}
155+
}
156+
157+
publishing.publications.all { publication ->
158+
publication.groupId = GROUP
159+
publication.version = VERSION_NAME
160+
161+
publication.artifact androidSourcesJar
162+
publication.artifact androidJavadocsJar
163+
164+
configurePom(publication.pom)
165+
}
166+
167+
signing {
168+
publishing.publications.all { publication ->
169+
sign publication
170+
}
171+
}
172+
}

0 commit comments

Comments
 (0)