Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add github action about docs and release #19

Merged
merged 3 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Docs

on: workflow_dispatch

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'zulu'

- name: Checkout
uses: actions/[email protected]

- name: Setup Docs
run: ./gradlew dokkaHtmlMultiModule

- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts repo is using docs branch. i think it would be nice to standardize it. it doesnt matter to me if that ends up being gh-pages or docs branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe gh-pages is a traditional branch for github pages, when created the setting was just updated directly so just use this. Is docs the one you picked?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I was under the impression that gh-pages and docs are both traditional choices. I went with docs as it sound nicer for what we intend it to be

folder: docs
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Release

on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release'
required: true
default: 'true'

jobs:
authorize:
name: Authorize
runs-on: ubuntu-18.04
steps:
- name: ${{ github.actor }} permission check to do a release

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work as intended? as far as i can recall, this doesn't take into account users under a, authorized group :\ i think ampli has a working one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using the one in Ampli for Typescript now? I will do some test later after merge, may need to update if it is not working well.

uses: octokit/[email protected]
with:
route: GET /repos/:repository/collaborators/${{ github.actor }}
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
runs-on: ubuntu-18.04
needs: [authorize]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Build
run: ./gradlew build

- name: Lint
run: ./gradlew ktlintCheck

- name: Test
run: ./gradlew test --info

- name: Configure GPG
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
run: |
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"

- name: Configure Sonatype
env:
GRADLE_PROP_FILE: local.properties
run: |
echo "ossrhUsername=${{ secrets.OSSRH_USERNAME }}" >> $GRADLE_PROP_FILE
echo "ossrhPassword=${{ secrets.OSSRH_PASSWORD }}" >> $GRADLE_PROP_FILE
echo "sonatypeStagingProfileId=${{ secrets.SONATYPE_STAGING_PROFILE_ID }}" >> $GRADLE_PROP_FILE
echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> $GRADLE_PROP_FILE
echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> $GRADLE_PROP_FILE
echo "signing.secretKeyRingFile=${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" >> $GRADLE_PROP_FILE

- name: Semantic Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: amplitude-sdk-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: amplitude-sdk-bot
GIT_COMMITTER_EMAIL: [email protected]
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @google/semantic-release-replace-plugin@1 \
-p @semantic-release/exec@5 \
semantic-release --dry-run

- name: Semantic Release
if: ${{ github.event.inputs.dryRun == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: amplitude-sdk-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: amplitude-sdk-bot
GIT_COMMITTER_EMAIL: [email protected]
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @google/semantic-release-replace-plugin@1 \
-p @semantic-release/exec@5 \
semantic-release
19 changes: 17 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ plugins {
id 'kotlin-android'
}

ext {
PUBLISH_NAME = 'Amplitude Android Kotlin SDK'
PUBLISH_DESCRIPTION = 'Amplitude Kotlin client-side SDK for Android'
PUBLISH_GROUP_ID = 'com.amplitude'
PUBLISH_VERSION = '0.1.0'
PUBLISH_ARTIFACT_ID = 'amplitude-android'
}

apply from: "${rootDir}/gradle/publish-module.gradle"
version = PUBLISH_VERSION

android {
compileSdk 31

Expand All @@ -11,8 +22,8 @@ android {

minSdk 16
targetSdk 31
versionCode 1
versionName "1.0"
versionName PUBLISH_VERSION
buildConfigField "String", "AMPLITUDE_VERSION", "\"${version}\""

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -59,3 +70,7 @@ dependencies {
testImplementation 'org.robolectric:robolectric:4.7.3'
testImplementation 'androidx.test:core:1.4.0'
}

tasks.dokkaHtmlPartial.configure {
failOnWarning.set(true)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amplitude.android.plugins

import com.amplitude.android.BuildConfig
import com.amplitude.android.Configuration
import com.amplitude.android.TrackingOptions
import com.amplitude.common.android.AndroidContextProvider
Expand Down Expand Up @@ -126,7 +127,7 @@ class AndroidContextPlugin : Plugin {
companion object {
const val PLATFORM = "Android"
const val SDK_LIBRARY = "amplitude-android-kotlin"
const val SDK_VERSION = "0.0.1"
const val SDK_VERSION = BuildConfig.AMPLITUDE_VERSION
private val INVALID_DEVICE_IDS = setOf("", "9774d56d682e549c", "unknown", "000000000000000", "Android", "DEFACE", "00000000-0000-0000-0000-000000000000")
fun validDeviceId(deviceId: String): Boolean {
return !(deviceId.isEmpty() || INVALID_DEVICE_IDS.contains(deviceId))
Expand Down
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
buildscript {
ext.kotlin_version = "1.5.10"
ext.dokka_version = '1.6.10'
repositories {
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
Expand All @@ -9,7 +10,9 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}

Expand All @@ -29,4 +32,17 @@ allprojects{
}

apply plugin: "org.jlleitschuh.gradle.ktlint"
}
apply plugin: 'org.jetbrains.dokka'
}

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(new File(rootDir, "docs"))
}

apply plugin: 'io.github.gradle-nexus.publish-plugin'

task clean(type: Delete) {
delete rootProject.buildDir
}

apply from: "${rootDir}/gradle/publish-root.gradle"
4 changes: 4 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ dependencies {
test {
useJUnitPlatform()
}

tasks.dokkaHtmlPartial.configure {
failOnWarning.set(true)
}
16 changes: 16 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,19 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
android.jetifier.ignorelist=bcprov-jdk15on-1.68.jar

POM_URL=https\://github.com/amplitude//Amplitude-Kotlin
POM_SCM_URL=https\://github.com/amplitude//Amplitude-Kotlin
POM_SCM_CONNECTION=scm\:[email protected]\:amplitude/Amplitude-Kotlin.git
POM_SCM_DEV_CONNECTION=scm\:[email protected]\:amplitude/Amplitude-Kotlin.git
POM_LICENCE_NAME=MIT
POM_LICENCE_URL=https\://opensource.org/licenses/MIT
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=amplitude_sdk_dev
POM_DEVELOPER_NAME=Amplitude SDK Developers
[email protected]
POM_DEVELOPER_ORG=Amplitude
POM_DEVELOPER_ORG_URL=https://amplitude.com/
RELEASE_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/
SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots/
86 changes: 86 additions & 0 deletions gradle/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'org.jetbrains.dokka'

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
pluginsMapConfiguration.set(
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
)
}

task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
archiveClassifier.set('javadoc')
from dokkaJavadoc.outputDirectory
}

artifacts {
archives androidSourcesJar
archives javadocJar
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION
if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
from components.java
}

artifact androidSourcesJar
artifact javadocJar

pom {
name = PUBLISH_NAME
description = PUBLISH_DESCRIPTION
url = POM_URL
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
email = POM_DEVELOPER_EMAIL
}
}
scm {
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
}
}
}
}
}
}

ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]

signing {
sign publishing.publications
}
34 changes: 34 additions & 0 deletions gradle/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Create variables with empty default values
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}
}
}
Loading