Skip to content

Commit

Permalink
ci: update semantic release (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinpaypal authored Mar 5, 2024
1 parent c79e439 commit a9a3fb8
Show file tree
Hide file tree
Showing 9 changed files with 12,372 additions and 6,829 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'microsoft'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'microsoft'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'microsoft'
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# pulls all commits (needed for semantic release to correctly version)
fetch-depth: '0'
persist-credentials: false

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'microsoft'
Expand All @@ -47,12 +47,15 @@ jobs:
- name: Install Semantic Release Dependencies
run: npm install

# TODO: update .releaserc.json with appropriate prepareCmd, successCmd, and assets
# TODO: enable semantic-release once fixed
# - name: GitHub Release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: npx semantic-release@21
- name: GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_KEY_FILE: ${{ env.SIGNING_KEY_FILE_PATH }}
run: npx semantic-release@21

- name: Publish to Maven
uses: ./.github/actions/publish_all_modules
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'microsoft'
Expand All @@ -28,13 +28,15 @@ jobs:
test_unit_coverage:
name: Unit Tests Coverage
runs-on: ubuntu-latest
# test coverage only runs on PRs
if: ${{ github.event_name == 'pull_request' }}

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand Down Expand Up @@ -63,10 +65,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -84,8 +86,8 @@ jobs:
- name: Show Test XML
run: |
mkdir -p library/build/outputs/androidTest-results/connected/logs
grep -E '(SUCCESS|FAILED|failed)' connectedCheck.log > library/build/outputs/androidTest-results/connected/logs/connectedCheck.xml
grep -E 'com.paypal.*Test.*(SUCCESS|FAILED|failed)' connectedCheck.log > library/build/outputs/androidTest-results/connected/logs/connectedCheck.xml
cat library/build/outputs/androidTest-results/connected/**/*.xml
echo ""
error_count=$(grep -E '(FAILED|failed|failure)' library/build/outputs/androidTest-results/connected/**/*.xml | wc -l | awk '{$1=$1};1')
error_count=$(grep -E 'com.paypal.*Test.*(FAILED|failed|failure)' library/build/outputs/androidTest-results/connected/**/*.xml | wc -l | awk '{$1=$1};1')
if [[ "$error_count" -ne "0" ]]; then echo "Tests failed. See above"; exit 1; fi
27 changes: 22 additions & 5 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"branches": ["main", {"name": "develop", "prerelease": true}, {"name": "prerelease", "prerelease": true}],
"branches": [
"release",
{"name": "develop", "prerelease": true},
{"name": "prerelease", "prerelease": true}
],
"tagFormat": "${version}",
"plugins": [
[
"@semantic-release/commit-analyzer",
Expand Down Expand Up @@ -43,21 +48,33 @@
[
"@semantic-release/exec",
{
"prepareCmd": "",
"successCmd": ""
"prepareCmd": "./gradlew --stacktrace -PversionParam=${nextRelease.version} changeReleaseVersion clean :library:assemble",
"successCmd": "echo"
}
],
[
"@semantic-release/git",
{
"assets": ["*"],
"assets": [
"gradle/*",
"library/*",
"readme-images/*",
"build.gradle",
"CHANGELOG.md",
"gradle.properties",
"gradlew",
"gradlew.bat",
"LICENSE",
"README.md",
"settings.gradle"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"assets": ""
"assets": ["library/build/outputs/aar/*.aar"]
}
]
]
Expand Down
18 changes: 15 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.jmailen.gradle.kotlinter.tasks.FormatTask

buildscript {
ext.modules = [
// TODO: How are we changing the versionName in the gradle files during release?
"sdkVersionCode" : 10000,
"sdkVersionName" : "1.0.0-alpha.00-SNAPSHOT",
"androidMinSdkVersion": 23,
Expand All @@ -16,7 +17,7 @@ plugins {
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 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'signing'
}

Expand All @@ -41,8 +42,8 @@ nexusPublishing {
sonatype {
username = System.getenv('SONATYPE_NEXUS_USERNAME') ?: ''
password = System.getenv('SONATYPE_NEXUS_PASSWORD') ?: ''
repositoryDescription = "Paypal Messages"
packageGroup = "com.paypal"
repositoryDescription = 'Paypal Messages'
packageGroup = 'com.paypal'
}
}
transitionCheckOptions {
Expand All @@ -54,3 +55,14 @@ nexusPublishing {
subprojects {
group = "com.paypal.messages"
}

//./gradlew -PversionParam=0.0.1 changeReleaseVersion
tasks.register('changeReleaseVersion') {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def updatedScript =
topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + versionParam + '",')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}
1 change: 1 addition & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ android {
minSdkVersion modules.androidMinSdkVersion
targetSdkVersion modules.androidTargetVersion

// TODO: Are versionCode and versionName needed for libraries here?
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down
Loading

0 comments on commit a9a3fb8

Please sign in to comment.