Skip to content

Commit

Permalink
update version to snapshot on env var
Browse files Browse the repository at this point in the history
  • Loading branch information
grablack committed Feb 22, 2024
1 parent f3118ba commit 2865222
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 2 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Snapshot Release
on:
workflow_dispatch: {}
env:
SIGNING_KEY_FILE_PATH: /home/runner/secretKey.gpg

jobs:
lint:
uses: ./.github/workflows/lint.yml

test:
uses: ./.github/workflows/test-release.yml

build:
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: Snapshot Release
needs: [lint, test, build]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
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
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'microsoft'

- 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: 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: Set Snapshot variable
id: set_var
run: echo "UPDATE_VERSION_SNAPSHOT=true" >> $GITHUB_ENV

# - name: Publish to Maven
# uses: ./.github/actions/publish_all_modules
# with:
# sonatype_user: ${{ secrets.SONATYPE_SDKS_NEXUS_USERNAME }}
# sonatype_password: ${{ secrets.SONATYPE_SDKS_NEXUS_PASSWORD }}
# signing_key_id: ${{ secrets.SIGNING_KEY_ID }}
# signing_key_password: ${{ secrets.SIGNING_KEY_PASSWORD }}
# signing_key_file: ${{ env.SIGNING_KEY_FILE_PATH }}
17 changes: 15 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jmailen.gradle.kotlinter.tasks.FormatTask

buildscript {
ext.modules = [
"sdkVersionCode" : 10000,
"sdkVersionName" : "1.0.0-alpha.00",
"androidMinSdkVersion": 23,
"androidTargetVersion": 34
Expand Down Expand Up @@ -34,7 +33,7 @@ tasks.register('ktFormat', FormatTask) {
report = file('build/reports/ktlint/format-report.txt')
}

version modules.sdkVersionName
// version modules.sdkVersionName

nexusPublishing {
repositories {
Expand All @@ -54,3 +53,17 @@ nexusPublishing {
subprojects {
group = "com.paypal.messages"
}

// Additional configuration based on the GitHub Actions environment variable
val updateVariable = System.getenv("UPDATE_VERSION_SNAPSHOT")

if (updateVariable != null && updateVariable.equals("true", ignoreCase = true)) {
android {
defaultConfig {
// Assume modules.sdkVersionName is a String variable
modules.sdkVersionName += "-SNAPSHOT"
}
}

println(modules.sdkVersionName)
}

0 comments on commit 2865222

Please sign in to comment.