Skip to content

Commit ef4f3a0

Browse files
authored
chore: Adding release workflow. (#7)
* chore: Adding release workflow. Change-Id: I6a5346c007ec1b83235c1a56b32d9c12508e984e * Adding required variables. Change-Id: Ic79a79dce2afc05a068553615e3915d124459486
1 parent b1c0fb1 commit ef4f3a0

File tree

6 files changed

+192
-12
lines changed

6 files changed

+192
-12
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Release
16+
on:
17+
push:
18+
branches: [ main ]
19+
workflow_dispatch:
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
with:
27+
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
28+
- name: Create .gpg key
29+
run: |
30+
echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc
31+
gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc
32+
33+
sed -i -e "s,sonatypeUsername=,sonatypeUsername=$SONATYPE_USERNAME,g" gradle.properties
34+
sed -i -e "s,sonatypePassword=,sonatypePassword=$SONATYPE_PASSWORD,g" gradle.properties
35+
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
36+
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
37+
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
38+
env:
39+
GPG_KEY_ARMOR: "${{ secrets.SYNCED_GPG_KEY_ARMOR }}"
40+
GPG_KEY_ID: ${{ secrets.SYNCED_GPG_KEY_ID }}
41+
GPG_PASSWORD: ${{ secrets.SYNCED_GPG_KEY_PASSWORD }}
42+
SONATYPE_PASSWORD: "${{ secrets.SYNCED_SONATYPE_PASSWORD }}"
43+
SONATYPE_USERNAME: ${{ secrets.SYNCED_SONATYPE_USERNAME }}
44+
45+
- name: Semantic Release
46+
uses: cycjimmy/semantic-release-action@v2
47+
with:
48+
extra_plugins: |
49+
"@semantic-release/commit-analyzer"
50+
"@semantic-release/release-notes-generator"
51+
"@google/semantic-release-replace-plugin"
52+
"@semantic-release/exec"
53+
"@semantic-release/git
54+
"@semantic-release/github
55+
env:
56+
GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}

.releaserc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
branches:
2+
- main
3+
plugins:
4+
- "@semantic-release/commit-analyzer"
5+
- "@semantic-release/release-notes-generator"
6+
- - "@google/semantic-release-replace-plugin"
7+
- replacements:
8+
- files:
9+
- "./build.gradle"
10+
from: "version = \".*\""
11+
to: "version = \"${nextRelease.version}\""
12+
- files:
13+
- "README.md"
14+
from: "rx:[0-9].[0-9].[0-9]"
15+
to: "rx:${nextRelease.version}"
16+
- - "@semantic-release/exec"
17+
- prepareCmd: "./gradlew build --warn --stacktrace"
18+
publishCmd: "./gradlew publish --warn --stacktrace"
19+
- - "@semantic-release/git"
20+
- assets:
21+
- "./build.gradle"
22+
- "README.md"
23+
- "@semantic-release/github"
24+
options:
25+
debug: true

build.gradle.kts

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,124 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import com.google.maps.android.rx.androidExtension
1516
import com.google.maps.android.rx.artifactId
1617

1718
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1819
buildscript {
1920
repositories {
2021
google()
21-
jcenter()
22+
mavenCentral()
2223
}
2324
dependencies {
2425
classpath("com.android.tools.build:gradle:4.1.2")
25-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21")
26+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
27+
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32")
2628
}
2729
}
2830

31+
plugins {
32+
`maven-publish`
33+
signing
34+
}
35+
36+
// Shared configs across subprojects
2937
allprojects {
3038
group = "com.google.maps.android"
3139
version = "0.1.0"
3240

3341
repositories {
3442
google()
35-
jcenter()
43+
mavenCentral()
3644
}
3745
}
3846

47+
// Publishing and signing info
3948
subprojects {
40-
if (project.artifactId() == null) return@subprojects
49+
if (project.artifactId == null) return@subprojects
4150

4251
apply(plugin = "com.android.library")
4352
apply(plugin = "kotlin-android")
53+
apply(plugin = "maven-publish")
54+
apply(plugin = "org.jetbrains.dokka")
55+
apply(plugin = "signing")
4456

45-
// TODO apply shared publishing
46-
}
57+
val sourcesJar = task<Jar>("sourcesJar") {
58+
archiveClassifier.set("sources")
59+
val libraryExtension = (project.androidExtension as com.android.build.gradle.LibraryExtension)
60+
from(libraryExtension.sourceSets["main"].java.srcDirs)
61+
}
4762

48-
task<Delete>("clean") {
49-
delete(rootProject.buildDir)
50-
}
63+
val dokkaHtml = tasks.named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml")
64+
val dokkaJavadoc = tasks.named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaJavadoc")
65+
val javadocJar = task<Jar>("javadocJar") {
66+
dependsOn(dokkaHtml)
67+
dependsOn(dokkaJavadoc)
68+
archiveClassifier.set("javadoc")
69+
from(buildDir.resolve("dokka/javadoc"))
70+
}
71+
72+
publishing {
73+
publications {
74+
create<MavenPublication>("aar") {
75+
groupId = project.group as String
76+
artifactId = project.artifactId
77+
version = project.version as String
78+
79+
pom {
80+
name.set(project.name)
81+
description.set("RxJava bindings for the Maps SDK for Android")
82+
url.set("https://github.com/googlemaps/android-maps-rx")
83+
84+
scm {
85+
connection.set("scm:git@github.com:googlemaps/android-maps-rx.git")
86+
developerConnection.set("scm:git@github.com:googlemaps/android-maps-rx.git")
87+
url.set("https://github.com/googlemaps/android-maps-rx")
88+
}
89+
90+
licenses {
91+
license {
92+
name.set("The Apache Software License, Version 2.0")
93+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
94+
distribution.set("repo")
95+
}
96+
}
97+
98+
organization {
99+
name.set("Google Inc.")
100+
url.set("https://developers.google.com/maps")
101+
}
102+
103+
developers {
104+
developer {
105+
name.set("Google Inc.")
106+
}
107+
}
108+
}
109+
110+
afterEvaluate {
111+
artifact(buildDir.resolve("outputs/aar/${project.name}-release.aar"))
112+
113+
artifact(javadocJar)
114+
artifact(sourcesJar)
115+
}
116+
}
117+
}
118+
119+
repositories {
120+
maven {
121+
name = "mavencentral"
122+
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
123+
credentials {
124+
username = properties["sonatypeUsername"] as String?
125+
password = properties["sonatypePassword"] as String
126+
}
127+
}
128+
}
129+
}
130+
131+
// Signing
132+
signing {
133+
sign(publishing.publications.findByName("aar"))
134+
}
135+
}

buildSrc/src/main/kotlin/com/google/maps/android/rx/Extensions.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
package com.google.maps.android.rx
1616

1717
import org.gradle.api.Project
18+
import org.gradle.api.plugins.ExtensionAware
1819

1920
/**
2021
* Returns the artifactId of this project. Returns null if the project is not a publishable
2122
* project.
2223
*/
23-
fun Project.artifactId() : String? =
24-
if (name == "maps-rx") name else null
24+
val Project.artifactId: String?
25+
get() =
26+
if (name == "maps-rx") name else null
27+
28+
val Project.androidExtension: Any
29+
get() = (this as ExtensionAware).extensions.getByName("android")

gradle.properties

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
21-
kotlin.code.style=official
21+
kotlin.code.style=official
22+
23+
# variables required to allow build.gradle to parse,
24+
# override in ~/.gradle/gradle.properties
25+
signing.keyId=
26+
signing.password=
27+
signing.secretKeyRingFile=
28+
29+
sonatypeUsername=
30+
sonatypePassword=

release.gpg.gpg

4.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)