Skip to content

Commit

Permalink
Add GithubActions tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylwester Zieliński committed Sep 10, 2021
1 parent 63b5f4b commit 63c1ac1
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 11 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/deploy-to-nexus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy to Nexus
on:
workflow_dispatch:
jobs:
restorePassword:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- shell: bash
env:
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
KEYSTORE_KEY_PSWD: ${{ secrets.KEYSTORE_KEY_PSWD }}
KEYSTORE_PSWD: ${{ secrets.KEYSTORE_PSWD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
OSSR_USERNAME: ${{ secrets.OSSR_USERNAME }}
OSSR_PASSWORD: ${{ secrets.OSSR_PASSWORD }}
SONATYPE_STATING_PROFILE_ID: ${{ secrets.SONATYPE_STATING_PROFILE_ID }}
run: |
pwd
echo "${{ secrets.KEYSTORE_FILE }}" > keystore.asc
gpg -d --passphrase "${{ secrets.KEYSTORE_FILE_PSWD }}" --batch keystore.asc > keystore
echo "${{ secrets.GPG_FILE }}" > sec.gpg.asc
gpg -d --passphrase "${{ secrets.GPG_FILE_PSWD }}" --batch sec.gpg.asc > sec.gpg
./gradlew publishReleasePublicationToSonatypeRepository
30 changes: 30 additions & 0 deletions .github/workflows/deploy-to-play-store.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy to Play Store Alpha
on:
workflow_dispatch:
jobs:
restorePassword:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/checkout@v1
- shell: bash
env:
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
KEYSTORE_KEY_PSWD: ${{ secrets.KEYSTORE_KEY_PSWD }}
KEYSTORE_PSWD: ${{ secrets.KEYSTORE_PSWD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
OSSR_USERNAME: ${{ secrets.OSSR_USERNAME }}
OSSR_PASSWORD: ${{ secrets.OSSR_PASSWORD }}
SONATYPE_STATING_PROFILE_ID: ${{ secrets.SONATYPE_STATING_PROFILE_ID }}
run: |
pwd
echo "${{ secrets.KEYSTORE_FILE }}" > keystore.asc
gpg -d --passphrase "${{ secrets.KEYSTORE_FILE_PSWD }}" --batch keystore.asc > keystore
echo "${{ secrets.GPG_FILE }}" > sec.gpg.asc
gpg -d --passphrase "${{ secrets.GPG_FILE_PSWD }}" --batch sec.gpg.asc > sec.gpg
echo "${{ secrets.API_KEY_FILE }}" > fastlane-api.json.asc
gpg -d --passphrase "${{ secrets.API_KEY_FILE_PSWD }}" --batch fastlane-api.json.asc > fastlane-api.json
fastlane deployAlpha
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Built application files
build/*
PGP/

keystore
keystore.encrypted
sec.gpg
fastlane-api.json

# Crashlytics configuations
com_crashlytics_export_strings.xml
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "fastlane"
2 changes: 2 additions & 0 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json_key_file("fastlane-api.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("no.nordicsemi.android.nrfconnectdevicemanager") # e.g. com.krausefx.app
69 changes: 69 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:android)

platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end

desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do
gradle(task: "clean assembleRelease")
crashlytics

# sh "your_script.sh"
# You can also use other beta testing services here
end

desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(task: "clean assembleRelease")
upload_to_play_store
end

desc "Deploy libraries to Nexus."
lane :deployNexus do
gradle(task: "clean assembleRelease")
gradle(task: "publishReleasePublicationToSonatypeRepository")
end

desc "Deploy build to Alpha channel."
lane :deployAlpha do
gradle(task: "clean assembleRelease")
upload_to_play_store(
track: 'alpha',
apk: 'sample/build/outputs/apk/release/sample-release.apk'
)
end

desc "Deploy build to Beta channel."
lane :deployBeta do
gradle(task: "clean assembleRelease")
upload_to_play_store(
track: 'beta',
apk: 'sample/build/outputs/apk/release/sample-release.apk'
)
end

desc "Generate internal Play Store link to the apk"
lane :deployInternal do
gradle(task: "clean assembleRelease")
upload_to_play_store_internal_app_sharing(apk: 'sample/build/outputs/apk/release/sample-release.apk')
end

end
59 changes: 59 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
fastlane documentation
================
# Installation

Make sure you have the latest version of the Xcode command line tools installed:

```
xcode-select --install
```

Install _fastlane_ using
```
[sudo] gem install fastlane -NV
```
or alternatively using `brew install fastlane`

# Available Actions
## Android
### android test
```
fastlane android test
```
Runs all the tests
### android beta
```
fastlane android beta
```
Submit a new Beta Build to Crashlytics Beta
### android deploy
```
fastlane android deploy
```
Deploy a new version to the Google Play
### android deployNexus
```
fastlane android deployNexus
```
Deploy libraries to Nexus.
### android deployAlpha
```
fastlane android deployAlpha
```
Deploy build to Alpha channel.
### android deployBeta
```
fastlane android deployBeta
```
Deploy build to Beta channel.
### android deployInternal
```
fastlane android deployInternal
```
Generate internal Play Store link to the apk

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
More information about fastlane can be found on [fastlane.tools](https://fastlane.tools).
The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
23 changes: 23 additions & 0 deletions fastlane/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="fastlane.lanes">




<testcase classname="fastlane.lanes" name="0: default_platform" time="0.00034406">

</testcase>


<testcase classname="fastlane.lanes" name="1: clean assembleRelease" time="38.882583065">

</testcase>


<testcase classname="fastlane.lanes" name="2: upload_to_play_store" time="8.269658704">

</testcase>

</testsuite>
</testsuites>
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
android.useAndroidX=true

VERSION_NAME=0.13.0
GROUP=no.nordicsemi.android

POM_DESCRIPTION=A mobile management library for devices running Apache Mynewt and Zephyr (DFU, logs, stats, config, etc.)
Expand Down
27 changes: 27 additions & 0 deletions gradle/git-tag-version.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ext.getVersionCodeFromTags = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine 'git', 'tag', '--list'
standardOutput = code
}
return 3 + code.toString().split("\n").size()
}
catch (ignored) {
return -1
}
}

ext.getVersionNameFromTags = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty'
standardOutput = stdout
}
return stdout.toString().trim().split("-")[0]
}
catch (ignored) {
return null
}
}
11 changes: 6 additions & 5 deletions gradle/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply from: rootProject.file("gradle/git-tag-version.gradle")

group = GROUP
version = VERSION_NAME
version = getVersionNameFromTags()

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
Expand All @@ -24,7 +25,7 @@ afterEvaluate {

groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME
version = getVersionNameFromTags()

pom {
name = POM_NAME
Expand Down Expand Up @@ -58,9 +59,9 @@ afterEvaluate {
}
}

ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
ext["signing.keyId"] = System.env.GPG_SIGNING_KEY
ext["signing.password"] = System.env.GPG_PASSWORD
ext["signing.secretKeyRingFile"] = "../sec.gpg"

signing {
sign publishing.publications
Expand Down
6 changes: 3 additions & 3 deletions gradle/publish-root.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ nexusPublishing {

repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
stagingProfileId = System.env.SONATYPE_STATING_PROFILE_ID
username = System.env.OSSR_USERNAME
password = System.env.OSSR_PASSWORD
}
}

Expand Down
1 change: 1 addition & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/release
15 changes: 13 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

apply plugin: 'com.android.application'
apply from: rootProject.file("gradle/git-tag-version.gradle")

android {
compileSdkVersion 30
Expand All @@ -13,22 +14,32 @@ android {
applicationId "no.nordicsemi.android.nrfconnectdevicemanager"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionCode getVersionCodeFromTags()
versionName getVersionNameFromTags()
resConfigs "en"

vectorDrawables.useSupportLibrary = true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
storeFile file('../keystore')
storePassword System.env.KEYSTORE_PSWD
keyAlias System.env.KEYSTORE_ALIAS
keyPassword System.env.KEYSTORE_KEY_PSWD
}
}

buildFeatures {
viewBinding true
}

buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release
}
}
}
Expand Down

0 comments on commit 63c1ac1

Please sign in to comment.