Skip to content

Commit

Permalink
feat: package pre-release (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
grablack committed Jan 11, 2024
1 parent 960a48a commit d63f834
Show file tree
Hide file tree
Showing 16 changed files with 7,221 additions and 81 deletions.
19 changes: 19 additions & 0 deletions .github/actions/decode_signing_key_action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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:
# After decoding the secret key, place the file in signing_file_path
- run: |
echo "${{inputs.signing_key_file}}" > ~/secretKey.gpg.b64
base64 -d ~/secretKey.gpg.b64 > ${{ inputs.signing_file_path }}
shell: bash
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_user:
description: 'Sonatype user'
required: true
default: ''
sonatype_password:
description: 'Sonatype password'
required: true
default: ''
signing_key_id:
description: 'Signing key id'
required: true
default: ''
signing_key_password:
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_user }}
SONATYPE_NEXUS_PASSWORD: ${{ inputs.sonatype_password }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
SIGNING_KEY_PASSWORD: ${{ inputs.signing_key_password }}
SIGNING_KEY_FILE: ${{ inputs.signing_key_file }}
53 changes: 53 additions & 0 deletions .github/workflows/build-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Demo
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-demo-${{ github.event.number }}
cancel-in-progress: true

jobs:
build-demo:
name: Build Demo
runs-on: ubuntu-latest

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

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

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'microsoft'
cache: gradle

- 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 :demo:assemble
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 }}."
41 changes: 31 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
name: Build
on: [pull_request, workflow_dispatch]
name: Build Library
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 }}
cancel-in-progress: true

jobs:
build:
name: Build
name: Build Library
runs-on: ubuntu-latest

strategy:
matrix:
codebase: [library, demo]
env:
SIGNING_KEY_FILE_PATH: /home/runner/secretKey.gpg

steps:
- name: Checkout repo
Expand All @@ -22,11 +34,20 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
distribution: 'microsoft'
cache: gradle

# Only library assets are needed for the build step
- name: Build with Gradle
run: ./gradlew :${{ matrix.codebase }}:assemble
- 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 :library:assemble
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 }}."
4 changes: 2 additions & 2 deletions .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 All @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
distribution: 'microsoft'
cache: gradle

- name: Run Lint
Expand Down
61 changes: 36 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
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]
name: Publish To Maven
needs: [lint, test, build]
runs-on: ubuntu-latest

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

steps:
- name: Checkout repo
- name: Checkout Repository
uses: actions/checkout@v3
with:
# pulls all commits (needed for semantic release to correctly version)
Expand All @@ -37,17 +36,29 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
distribution: 'microsoft'

- name: Install Dependencies
run: |
npm i -g @semantic-release/exec @semantic-release/changelog @semantic-release/git conventional-changelog-conventionalcommits@6.1.0
- 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: GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release@21
- 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: Publish to Maven
run: echo "Publish to Maven"
uses: ./.github/actions/publish_all_modules
with:
sonatype_user: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatype_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 }}
4 changes: 2 additions & 2 deletions .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 All @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
distribution: 'microsoft'
cache: gradle

- name: Run Tests
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
.cxx
local.properties

# Node
node_modules/

# Recommended Ignores by JetBrains
# https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# .idea/ files are handled in .idea/.gitignore
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org
64 changes: 64 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"branches": ["main", {"name": "develop", "prerelease": true}, {"name": "prerelease", "prerelease": true}],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "type": "refactor", "release": "patch" },
{ "type": "perf", "release": "patch" },
{ "type": "style", "release": "patch" },
{ "type": "revert", "release": "patch" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
{ "type": "perf", "section": "Performance Improvements" },
{ "type": "revert", "section": "Reverts" },
{ "type": "docs", "section": "Documentation" },
{ "type": "style", "section": "Styles" },
{ "type": "chore", "section": "Miscellaneous Chores", "hidden": true },
{ "type": "refactor", "section": "Code Refactoring" },
{ "type": "test", "section": "Tests" },
{ "type": "build", "section": "Build System" },
{ "type": "ci", "section": "Continuous Integration" }
]
}
}
],
[
"@semantic-release/changelog",
{
"changelogTitle": "# Changelog"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "",
"successCmd": ""
}
],
[
"@semantic-release/git",
{
"assets": ["*"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"assets": ""
}
]
]
}

0 comments on commit d63f834

Please sign in to comment.