Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
tanderson-ld committed Apr 10, 2024
1 parent 8e94d99 commit ac22da0
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 10 deletions.
11 changes: 4 additions & 7 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
# additional package specific steps.
name: Shared CI Workflow
inputs:
package_name:
description: 'Name of the package.'
required: true
package_path:
workspace_path:
description: 'Path to the package.'
required: true
run_tests:
Expand All @@ -33,14 +30,14 @@ runs:
- name: Restore dependencies
shell: bash
id: restore
run: ${{ inputs.package_path }}/gradlew dependencies -p ${{ inputs.package_path }}
run: ${{ inputs.workspace_path }}/gradlew dependencies -p ${{ inputs.workspace_path }}

- name: Build
shell: bash
id: build
run: ${{ inputs.package_path }}/gradlew jar -p ${{ inputs.package_path }}
run: ${{ inputs.workspace_path }}/gradlew jar -p ${{ inputs.workspace_path }}

- name: Run Tests
if: steps.build.outcome == 'success' && inputs.run_tests == 'true'
shell: bash
run: ${{ inputs.package_path }}/gradlew test -p ${{ inputs.package_path }}
run: ${{ inputs.workspace_path }}/gradlew test -p ${{ inputs.workspace_path }}
43 changes: 43 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Package
description: 'Publish the package to Sonatype'
inputs:
workspace_path:
description: 'Path to the workspace.'
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true
prerelease:
description: 'Is this a prerelease. If so then it will be published to the staging repository only.'
required: true
signing_key_id:
description: 'Signing key ID'
required: true
signing_key_passphrase:
description: 'Signing key passphrase'
required: true
code_signing_keyring:
description: 'The path of the code signing keyring.'
required: true
sonatype_username:
description: 'Sonatype repo username.'
required: true
sonatype_password:
description: 'Sonatype repo password.'
required: true

runs:
using: composite
steps:
- name: Publish Library
shell: bash
env:
WORKSPACE_PATH: ${{ inputs.workspace_path }}
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
SIGNING_KEY_PASSPHRASE: ${{ inputs.signing_key_passphrase }}
SIGNING_SECRET_KEY_RING_FILE: ${{ inputs.code_signing_keyring }}
SONATYPE_USER_NAME: ${{ inputs.sonatype_username }}
SONATYPE_PASSWORD: ${{ inputs.sonatype_password }}
run: source $GITHUB_ACTION_PATH/publish.sh
22 changes: 22 additions & 0 deletions .github/actions/publish/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -ue

if $LD_RELEASE_IS_DRYRUN ; then
echo "Doing a dry run of publishing."
else
echo "Publishing to Sonatype"
if [ "${LD_RELEASE_IS_PRERELEASE}" == "true" ]; then
echo "PRERELEASE"
${WORKSPACE_PATH}/gradlew publishToSonatype -p ${WORKSPACE_PATH} -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.password="${SIGNING_KEY_PASSPHRASE}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PsonatypeUsername="${SONATYPE_USER_NAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" || {
echo "Gradle publish/release failed" >&2
exit 1
}
else
echo "RELEASE"
${WORKSPACE_PATH}/gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -p ${WORKSPACE_PATH} -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.password="${SIGNING_KEY_PASSPHRASE}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PsonatypeUsername="${SONATYPE_USER_NAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" || {
echo "Gradle publish/release failed" >&2
exit 1
}
fi
fi
5 changes: 2 additions & 3 deletions .github/workflows/ldotel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: shared
name: Shared CI Steps

- name: Shared CI Steps
uses: ./.github/actions/ci
with:
package_name: 'ldotel'
package_path: 'lib/ldotel'
java_version: 8
54 changes: 54 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish Package
on:
workflow_dispatch:
inputs:
workspace_path:
description: 'The workspace to publish'
required: true
type: choice
options:
- lib/libotel
prerelease:
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
type: boolean
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
type: boolean
default: true

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3

- name: Shared CI Steps
uses: ./.github/actions/ci
with:
package_path: '${{ inputs.package_path }}
java_version: 8
- uses: launchdarkly/gh-actions/actions/[email protected]
name: Get secrets
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/sonatype/username = SONATYPE_USER_NAME,
/production/common/releasing/sonatype/password = SONATYPE_PASSWORD
/production/common/releasing/java/keyId = SIGNING_KEY_ID'
s3_path_pairs: 'launchdarkly-releaser/java/code-signing-keyring.gpg = code-signing-keyring.gpg'

- name: Publish
uses: ./.github/actions/publish
with:
workspace_path: ${{ inputs.workspace_path }}
dry_run: ${{ inputs.dry_run }}
prerelease: ${{ inputs.prerelease }}
code_signing_keyring: 'code-signing-keyring.gpg'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/*
.vscode

0 comments on commit ac22da0

Please sign in to comment.