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

ci: add github workflows #2

Merged
merged 2 commits into from
May 11, 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
69 changes: 69 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Build and Test"
on: [push, pull_request]
jobs:
unit-tests:
name: "Unit Tests"
timeout-minutes: 15
runs-on: ubuntu-18.04
steps:
- name: "Checkout Branch"
uses: actions/checkout@v2
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{github.head_ref}}
- name: "Install JDK 11"
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- name: "Run Unit Tests"
run: ./gradlew test
- name: "Print Android Unit Tests Report"
uses: asadmansr/android-test-report-action@v1.2.0
if: ${{ always() }}
- name: "Archive Unit Test Results"
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: "unit-tests-results"
path: ./**/build/reports/**
# lint-checks:
# name: "Lint Checks"
# timeout-minutes: 15
# runs-on: macos-latest
# steps:
# - name: "Checkout Branch"
# uses: actions/checkout@v2
# - name: "Install JDK 11"
# uses: actions/setup-java@v2
# with:
# distribution: "zulu"
# java-version: "11"
# - name: "Run Android Core SDK Lint"
# run: ./gradlew lint
# - name: "Archive Lint Test Results"
# uses: actions/upload-artifact@v2
# if: ${{ always() }}
# with:
# name: "lint-results"
# path: ./**/build/reports/**
kotlin-lint-checks:
name: "Kotlin Lint Checks"
timeout-minutes: 15
runs-on: macos-latest
steps:
- name: "Checkout Branch"
uses: actions/checkout@v2
- name: "Install JDK 11"
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- name: "Run Android Core SDK Kotlin Lint"
run: ./gradlew ktlintCheck
- name: "Archive Kotlin Lint Test Results"
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: "kotlin-lint-results"
path: ./**/build/reports/**
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "Release"
on:
workflow_dispatch:
inputs:
dryRun:
description: "Do a dry run to preview instead of a real release [true/false]"
required: true
default: "false"

jobs:
semantic-release:
name: "Semantic Release"
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: "Checkout public main branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
- name: "Import GPG Key"
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: "Semantic Release --dry-run"
if: ${{ github.event.inputs.dryRun == 'true' }}
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
-p conventional-changelog-conventionalcommits \
semantic-release --dry-run
- name: "Semantic Release"
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
-p conventional-changelog-conventionalcommits \
semantic-release
- name: "Push automated release commits to release branch"
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push origin main

sonatype-release:
name: "Sonatype Release"
needs: semantic-release
runs-on: macos-latest
if: ${{ github.event.inputs.dryRun == 'false' }}
env:
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
mavenSigningKeyId: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY }}
mavenSigningKeyPassword: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSWORD }}
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
ref: main
- name: "Install JDK 11"
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- name: "Publish Android To Sonatype"
run: |
./gradlew -PisRelease=true publishReleasePublicationToMavenRepository --stacktrace
15 changes: 15 additions & 0 deletions .github/workflows/reusable-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "PR Reusable Checks"

on:
pull_request:

jobs:
pr-branch-check-name:
name: "Check PR for semantic branch name"
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable
pr-title-check:
name: "Check PR for semantic title"
uses: mParticle/mparticle-workflows/.github/workflows/pr-title-check.yml@stable
pr-branch-target-gitflow:
name: "Check PR for semantic target branch"
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-target-continuous.yml@stable
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# built application files
*.apk
*.ap_
*.bak

# files for the dex VM
*.dex
Expand Down
119 changes: 119 additions & 0 deletions .scripts/maven.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

allprojects {
ext."signing.keyId" = System.getenv("mavenSigningKeyId")
ext."signing.secretKeyRingFile" = System.getenv("mavenSigningKeyRingFile")
ext."signing.password" = System.getenv("mavenSigningKeyPassword")
}

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

if (project.tasks.findByName('generateJavadocsJar')) {
artifact project.tasks.getByName('mediaSdkJavadoc')
}
if (project.tasks.findByName('generateSourcesJar')) {
artifact project.tasks.getByName('generateSourcesJar')
}

pom {
name = project.ext.kitDescription
description = project.ext.kitDescription
url = "https://github.com/mParticle/mparticle-android-media-sdk"
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'https://www.apache.org/license/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'mParticle'
name = 'mParticle Inc.'
email = 'developers@mparticle.com'
}
}
scm {
url = 'https://github.com/mparticle/mparticle-android-media-sdk'
connection = 'scm:git:https://github.com/mparticle/mparticle-android-media-sdk'
developerConnection = 'scm:git:git@github.com:mparticle/mparticle-android-media-sdk.git'
}
}
}
debug(MavenPublication) {
groupId = "com.mparticle"
artifactId = "android-media"
version = project.version
if (project.plugins.findPlugin("com.android.library")) {
from components.debug
} else {
from components.java
}

if (project.tasks.findByName('generateJavadocsJar')) {
artifact project.tasks.getByName('generateJavadocsJar')
}

if (project.tasks.findByName('generateSourcesJar')) {
artifact project.tasks.getByName('generateSourcesJar')
}

pom {
name = project.ext.kitDescription
description = project.ext.kitDescription
url = 'https://github.com/mparticle/mparticle-sdk-android'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'https://www.apache.org/license/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'mParticle'
name = 'mParticle Inc.'
email = 'developers@mparticle.com'
}
}
scm {
url = 'https://github.com/mparticle/mparticle-android-sdk'
connection = 'scm:git:https://github.com/mparticle/mparticle-android-sdk'
developerConnection = 'scm:git:git@github.com:mparticle/mparticle-android-sdk.git'
}
}
}
}
repositories {
maven {
credentials {
username System.getenv('sonatypeUsername')
password System.getenv('sonatypePassword')
}
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
}
}

def signingKey = System.getenv("mavenSigningKeyId")
def signingPassword = System.getenv("mavenSigningKeyPassword")
signing {
required { gradle.taskGraph.hasTask("publishReleasePublicationToMavenRepository") }
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.release
}
}

//Publishing task aliases for simpler local development
task publishLocal { dependsOn "publishDebugPublicationToMavenLocal" }
task publishReleaseLocal { dependsOn "publishReleasePublicationToMavenLocal" }
11 changes: 11 additions & 0 deletions .scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
: ${1?"Version missing - usage: $0 x.y.z"}

#update build.gradle.kts
sed -i '.bak' "s/version=.*/version=$1/g" gradle.properties

#update README.md
sed -i '.bak' "s/'com.mparticle:android-media:.*'/'com.mparticle:android-media:$1'/g" README.md

#commit the version bump, tag, and push to private and public
git add gradle.properties
23 changes: 0 additions & 23 deletions build.gradle

This file was deleted.

16 changes: 16 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("org.sonarqube") apply true
id("org.jlleitschuh.gradle.ktlint") apply true
}

allprojects {
group = project.properties["group"].toString()
version = project.properties["version"].toString()
if (project.hasProperty("isRelease")) {
version = version.toString().replace("-SNAPSHOT", "")
}
repositories {
google()
mavenCentral()
}
}
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
kotlin.code.style=official
android.useAndroidX=true
android.useAndroidX=true
android.nonTransitiveRClass=true

group=com.mparticle
version=1.3.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
Loading