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: Package Pre-Release #14

Merged
merged 69 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a6bc34c
gradle files
grablack Nov 20, 2023
fd1f625
add github action
grablack Nov 20, 2023
e0a68c4
add properties
grablack Nov 20, 2023
068748e
manual versions
grablack Dec 1, 2023
b26570a
builldType release
grablack Dec 1, 2023
3e2c56c
inside android
grablack Dec 1, 2023
c9f24f3
copy buildtype structure
grablack Dec 1, 2023
03c10b5
remove unneeded edits
grablack Dec 5, 2023
0141739
rename
grablack Dec 6, 2023
31c1524
remove plugin
grablack Dec 6, 2023
82ce7fa
update name
grablack Dec 6, 2023
8d70d51
update build
grablack Dec 8, 2023
2baa4c1
signing plugin
grablack Dec 11, 2023
ead9d89
remove
grablack Dec 11, 2023
683d9fd
uncomment
grablack Dec 12, 2023
f4dced6
change case
grablack Dec 12, 2023
c4bbffb
Merge branch 'develop' into feat/pre-release-pack-2627
grablack Dec 13, 2023
d4cae59
build w gradle is same as assemble
grablack Dec 13, 2023
073dcb7
update version
grablack Dec 13, 2023
bb8fb9a
copy over build_aar
grablack Dec 13, 2023
f31b56a
remove input and build_aar
grablack Dec 13, 2023
e903ddb
no secret
grablack Dec 14, 2023
3a4945f
remove branch name
grablack Dec 14, 2023
32c1d97
use this branchname
grablack Dec 14, 2023
6195470
try local path
grablack Dec 14, 2023
170a48f
empty workflow_call
grablack Dec 14, 2023
5f469c7
local with branch
grablack Dec 14, 2023
a96670a
back to release
grablack Dec 14, 2023
048a30a
dont call as local
grablack Dec 14, 2023
96e0f5d
back to local
grablack Dec 14, 2023
706fce2
add push
grablack Dec 14, 2023
fc7bc24
add workflow_call
grablack Dec 15, 2023
a186dbd
allow secrets
grablack Dec 15, 2023
ce4c870
require
grablack Dec 15, 2023
48b7f3f
pass secrets
grablack Dec 15, 2023
5796291
update java version
grablack Dec 15, 2023
df28180
try fix dep
grablack Dec 18, 2023
70d7b12
task for dependency
grablack Dec 18, 2023
0ec0588
as input
grablack Dec 18, 2023
89c7a04
comment out
grablack Dec 18, 2023
cbd35e5
no artifact
grablack Dec 18, 2023
31a8005
add subproject
grablack Dec 18, 2023
265dcea
update ext name
grablack Dec 19, 2023
84e58b8
remove namespace
grablack Dec 19, 2023
639efbb
keep namespace
grablack Dec 19, 2023
2482aea
update url
grablack Dec 19, 2023
4e8ba41
specifiy the urls
grablack Dec 19, 2023
a3ae992
update urls
grablack Dec 19, 2023
a9fe7d2
change name back
grablack Dec 19, 2023
e5d0a4d
update url
grablack Dec 19, 2023
d7f2160
add snapshots
grablack Dec 19, 2023
b39a163
remove commented section
grablack Dec 19, 2023
e70fc54
attempt deploy without url
grablack Dec 20, 2023
d398c64
restore artifact line
grablack Dec 20, 2023
1f3723d
add artifact back
grablack Dec 20, 2023
7ebcde0
bring back task
grablack Dec 20, 2023
336d203
try variant
grablack Dec 20, 2023
13bfa58
restore to working
grablack Dec 20, 2023
f745ebc
try adding repo
grablack Dec 20, 2023
9fa5c5d
try new push
grablack Dec 20, 2023
03f18f3
unused buildscript
grablack Jan 8, 2024
fbf3d68
update names
grablack Jan 8, 2024
eb9c78e
distribution and yml changes
grablack Jan 8, 2024
f8f4315
split out demo build
grablack Jan 8, 2024
4926e94
unify version
grablack Jan 8, 2024
c74f8d6
make builds diff group
grablack Jan 8, 2024
f12bc80
use same var
grablack Jan 8, 2024
e674538
Add further fixes
merlinpaypal Jan 10, 2024
06bc1f1
update name
grablack Jan 11, 2024
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
18 changes: 18 additions & 0 deletions .github/actions/decode_signing_key_action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Decode signing key
description: 'Decodes gpg key into file'
inputs:
signing_key_file:
description: 'Signing key file'
required: true
default: ''
signing_file_path:
description: 'Signing file path'
required: true
default: ''
runs:
using: "composite"
steps:
- run: |
echo "${{inputs.signing_key_file}}" > ~/secretKey.gpg.b64
base64 -d ~/secretKey.gpg.b64 > ${{ inputs.signing_file_path }}
shell: bash
merlinpaypal marked this conversation as resolved.
Show resolved Hide resolved
35 changes: 35 additions & 0 deletions .github/actions/publish_all_modules/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Publish All Modules'
description: 'Publishes all modules'
inputs:
sonatype_usr:
description: 'Sonatype user'
required: true
default: ''
sonatype_pwd:
description: 'Sonatype password'
required: true
default: ''
signing_key_id:
description: 'Signing key id'
required: true
default: ''
signing_key_pwd:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's spell out sonatype_usr, sonatype_pwd, and signing_key_pwd instead of abbreviating for clarity sake

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

description: 'Signing key password'
required: true
default: ''
signing_key_file:
description: 'Signing key file'
required: true
default: ''
runs:
using: "composite"
steps:
- run: |
./gradlew --stacktrace clean publishToSonatype closeAndReleaseSonatypeStagingRepository
shell: bash
env:
SONATYPE_NEXUS_USERNAME: ${{ inputs.sonatype_usr }}
SONATYPE_NEXUS_PASSWORD: ${{ inputs.sonatype_pwd }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
SIGNING_KEY_PASSWORD: ${{ inputs.signing_key_pwd }}
SIGNING_KEY_FILE: ${{ inputs.signing_key_file }}
35 changes: 31 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
name: Build
on: [pull_request, workflow_dispatch]
on:
pull_request: {}
workflow_dispatch: {}
workflow_call:
secrets:
SIGNING_KEY_ID:
description: 'Secret Key ID'
required: true
SIGNING_KEY_FILE:
description: 'Secret Key'
required: true
SIGNING_KEY_PASSWORD:
description: 'Secret Password'
required: true

concurrency:
group: build-${{ github.event.number }}
Expand All @@ -10,6 +23,9 @@ jobs:
name: Build
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're using this as part of our release step, let's create a separate job for building the demo. While the demo isn't needed for releases, we do want to ensure it's buildable on each PR.

This also means that the strategy matrix in this job can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created separate job

runs-on: ubuntu-latest

env:
SIGNING_KEY_FILE_PATH: /home/runner/secretKey.gpg

strategy:
matrix:
codebase: [library, demo]
Expand All @@ -25,8 +41,19 @@ jobs:
distribution: 'temurin'
cache: gradle

# Only library assets are needed for the build step
- name: Build with Gradle
run: ./gradlew :${{ matrix.codebase }}:assemble
#After decoding the secret key, place the file in ~ /. Gradle/ secring.gpg
- name: Decode Signing Key
uses: ./.github/actions/decode_signing_key_action
with:
signing_key_file: ${{ secrets.SIGNING_KEY_FILE }}
signing_file_path: ${{ env.SIGNING_KEY_FILE_PATH }}

- name: Assemble
run: ./gradlew --stacktrace assemble -x :demo:assemble # we exclude Demo module in assemble
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we only have the one module, we should be able to just call ./gradlew --stacktrace assemble :library:assemble

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_KEY_FILE: ${{ env.SIGNING_KEY_FILE_PATH }}

- run: echo "Build status report=${{ job.status }}."

2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Lint
on: [pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch, workflow_call]

concurrency:
group: lint-${{ github.event.number }}
Expand Down
69 changes: 33 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
name: Release
on:
workflow_dispatch: {}
push:
branches:
- main
env:
SIGNING_KEY_FILE_PATH: /home/runner/secretKey.gpg

jobs:
lint:
uses: paypal/paypal-messages-android/.github/workflows/lint.yml@release
uses: ./.github/workflows/lint.yml

test:
uses: paypal/paypal-messages-android/.github/workflows/test.yml@release
uses: ./.github/workflows/test.yml

build:
uses: paypal/paypal-messages-android/.github/workflows/build.yml@release

uses: ./.github/workflows/build.yml
secrets:
SIGNING_KEY_FILE: ${{ secrets.SIGNING_KEY_FILE }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}

# after build and unit tests are finished, publish all modules at once
# to help reduce the probability of failure when interacting with sonatype servers
release:
name: Release
needs: [linting, tests, build]
needs: [lint, test, build]
name: Publish To Sonatype
runs-on: ubuntu-latest

permissions:
contents: write
issues: write
pull-requests: write

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
# pulls all commits (needed for semantic release to correctly version)
fetch-depth: '0'
persist-credentials: false

- name: Set up JDK 17
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Install Dependencies
run: |
npm i -g @semantic-release/exec @semantic-release/changelog @semantic-release/git [email protected]

- name: GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release@21
Copy link
Contributor

Choose a reason for hiding this comment

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

We still want to keep a GitHub release in line with our published packages, so these should stick around in some fashion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added back


distribution: 'microsoft'
Copy link
Contributor

@merlinpaypal merlinpaypal Jan 5, 2024

Choose a reason for hiding this comment

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

I'm checking with Steven on the difference but if we're updating the distribution here, we should probably update it everywhere for consistency

Steven said it shouldn't matter which one we use, but since that team is using Microsoft, let's switch it everywhere to Microsoft

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good

- name: Decode Signing Key
uses: ./.github/actions/decode_signing_key_action
with:
signing_key_file: ${{ secrets.SIGNING_KEY_FILE }}
signing_file_path: ${{ env.SIGNING_KEY_FILE_PATH }}
# - name: Update Version
# run: |
# ./gradlew -PversionParam=${{ github.event.inputs.version }} changeReleaseVersion
- name: Publish to Maven
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it says "Publish to Maven" but above it says "Publish to Sonatype". Why the difference?

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 think I didn't see name when I updated it. I'll make them align

run: echo "Publish to Maven"
uses: ./.github/actions/publish_all_modules
with:
sonatype_usr: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatype_pwd: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
signing_key_id: ${{ secrets.SIGNING_KEY_ID }}
signing_key_pwd: ${{ secrets.SIGNING_KEY_PASSWORD }}
signing_key_file: ${{ env.SIGNING_KEY_FILE_PATH }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Test
on: [pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch, workflow_call]

concurrency:
group: test-${{ github.event.number }}
Expand Down
39 changes: 39 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@
import org.jmailen.gradle.kotlinter.tasks.LintTask
import org.jmailen.gradle.kotlinter.tasks.FormatTask

buildscript {
ext.modules = [
"sdkVersionName" : "1.0.1-SNAPSHOT",
"sdkVersionCode" : 18,
"androidMinSdkVersion": 21,
"androidTargetVersion": 30
]

ext.versions = [
"kotlin" : "1.8.21",
"compose" : "1.4.7",
"navigation": "2.3.5",
"hilt" : "2.44"
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Where are these module and version variables used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not used. Removing

}

plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.22' apply false
id 'org.jmailen.kotlinter' version '3.16.0'
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id 'signing'
}

tasks.register('ktLint', LintTask) {
Expand All @@ -22,3 +40,24 @@ tasks.register('ktFormat', FormatTask) {
source files('demo/src', 'library/src')
report = file('build/reports/ktlint/format-report.txt')
}

version "1.0.0-alpha.00-SNAPSHOT" // we add it here so that nexus automatically chooses staging or snapshot repo
Copy link
Contributor

Choose a reason for hiding this comment

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

We have the version as a hardcoded string in 4 places. Is there a way we can define the version in one place and use a variable everywhere else?

We also have 1.0.1-SNAPSHOT above in buildscript. Should that be the same version as here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

defined in 1 place


nexusPublishing {
repositories {
sonatype {
username = System.getenv('SONATYPE_NEXUS_USERNAME') ?: ''
password = System.getenv('SONATYPE_NEXUS_PASSWORD') ?: ''
repositoryDescription = "Paypal Messages"
packageGroup = "com.paypal"
}
}
transitionCheckOptions {
// give nexus sonatype more time to close the staging repository
delayBetween.set(Duration.ofSeconds(20))
}
}

subprojects {
group = "com.paypal.messages"
}
16 changes: 16 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ kotlin.code.style=official
android.nonTransitiveRClass=true
android.suppressUnsupportedCompileSdk=34
android.defaults.buildfeatures.buildconfig=true

POM_PACKAGING=aar
#TODO: needs to be defined
POM_URL=not_defined

POM_SCM_URL=https://github.com/paypal/paypal-messages-android
POM_SCM_CONNECTION=scm:[email protected]:paypal/paypal-messages-android.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:paypal/paypal-messages-android.git

POM_LICENCE_NAME=The Apache License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0

POM_DEVELOPER_ID=paypal-messages-android
POM_DEVELOPER_NAME=PayPalMessages Android
#TODO: needs to be defined
POM_DEVELOPER_EMAIL=not_defined
67 changes: 67 additions & 0 deletions gradle/gradle-publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'


ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ?: ''
ext["signing.password"] = System.getenv('SIGNING_KEY_PASSWORD') ?: ''
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEY_FILE') ?: ''

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId group
version project.ext.version
artifactId project.ext.name
from components.release
// artifact androidSourcesJar //TODO: add javadocs

pom {
name = project.ext.pom_name ?: ''
packaging = POM_PACKAGING
description = project.ext.pom_desc ?: ''
url = POM_URL
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
}
}
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
}
}

}
}
repositories {
maven {
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
}
}
}

signing {
sign publishing.publications
sign configurations.archives
}
}

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
}

artifacts {
archives androidSourcesJar
}
Loading
Loading