Skip to content

Commit

Permalink
ci: release please support (#241)
Browse files Browse the repository at this point in the history
**Requirements**

- [ ] I have added test coverage for new or changed functionality
No behavioral changes in this PR.

- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)

- [ ] I have validated my changes against all supported platform
versions
Ongoing, have TODO related to API/Java version combinations, but would
like to get this portion merged to unblock utilizing release please for
a pending bugfix. Planning to fix the matrices in a subsequent PR.

**Related issues**

SC-234641

**Describe the solution you've provided**

Adds CI, docs, publishing, and release please actions.
  • Loading branch information
tanderson-ld authored Mar 6, 2024
1 parent caffab8 commit 7103634
Show file tree
Hide file tree
Showing 41 changed files with 635 additions and 274 deletions.
169 changes: 0 additions & 169 deletions .circleci/config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''
---

**Is this a support request?**
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/hc/en-us/requests/new) or by emailing support@launchdarkly.com.
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the code in this library. If you're not sure whether the problem you are having is specifically related to this library, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/) and clicking "submit a request", or by emailing support@launchdarkly.com.

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Expand Down
9 changes: 9 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Build Documentation
description: 'Build Documentation.'

runs:
using: composite
steps:
- name: Build Documentation
shell: bash
run: ./gradlew javadoc
59 changes: 59 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI Workflow
description: 'Shared CI workflow.'
inputs:
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
required: false
default: 'true'
android_api_level:
description: 'The Android API level to use.'
required: true
java_version:
description: 'The Java version to use.'
required: true
java_distribution:
description: 'The Java distribution to use.'
required: false
default: 'temurin'

runs:
using: composite
steps:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.java_distribution }}
java-version: ${{ inputs.java_version }}

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Build
shell: bash
id: build
run: ./gradlew build jar

- name: Run Unit Tests
if: inputs.run_tests == 'true'
shell: bash
run: ./gradlew test

- name: Build contract tests
shell: bash
run: make build-contract-tests

- name: Perform Instrumented Tests
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 #2.30.1
with:
api-level: ${{ inputs.android_api_level }}
target: google_apis
emulator-boot-timeout: 900
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
make start-contract-test-service
make run-contract-tests
./gradlew connectedDebugAndroidTest
- name: Build documentation
uses: ./.github/actions/build-docs
24 changes: 24 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish Documentation
description: 'Publish the documentation to Github pages'
inputs:
token:
description: 'Token to use for publishing.'
required: true
dry_run:
description: 'Is this a dry run. If so no docs will be published.'
required: true

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.1
name: 'Publish to Github pages'
if: ${{ inputs.dry_run == 'false' }}
with:
docs_path: launchdarkly-android-client-sdk/build/docs/javadoc
github_token: ${{ inputs.token }} # For the shared action the token should be a GITHUB_TOKEN

- name: Dry Run Publish Docs
shell: bash
if: ${{ inputs.dry_run == 'true' }}
run: echo "Dry run. Not publishing docs."
28 changes: 28 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish Package
description: 'Publish the package to Sonatype'
inputs:
code_signing_keyring:
description: 'The path of the code signing keyring.'
required: true
prerelease:
description: 'Is this a prerelease. If so then it will be published to the staging repository only.'
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true

runs:
using: composite
steps:
- name: Publish Library
shell: bash
if: ${{ inputs.dry_run == 'false' }}
env:
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
SIGNING_SECRET_KEY_RING_FILE: ${{ inputs.code_signing_keyring }}
run: source $GITHUB_ACTION_PATH/publish.sh

- name: Dry Run Publish Library
shell: bash
if: ${{ inputs.dry_run == 'true' }}
run: echo "Dry run. Not publishing."
18 changes: 18 additions & 0 deletions .github/actions/publish/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -ue

echo "Publishing to Sonatype"
if [ "${LD_RELEASE_IS_PRERELEASE}" == "true" ]; then
echo "PRERELEASE"
./gradlew publishToSonatype -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"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -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
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Test
on:
workflow_dispatch:
push:
branches: ['main']
paths-ignore:
- '**.md' # Do not need to run CI for markdown changes.
pull_request:
branches: [ 'main' ]
paths-ignore:
- '**.md'

jobs:
ci-build:
strategy:
matrix:
# TODO: Use full matrices
# android_api_level: ['21','25','30','34']
# java_version: ['11', '17']
android_api_level: ['25']
java_version: ['17']
runs-on: ubuntu-latest

steps:
# This enables hardware acceleration on large linux runners
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: actions/checkout@v4
- uses: ./.github/actions/ci
with:
android_api_level: ${{ matrix.android_api_level }}
java_version: ${{ matrix.java_version }}
12 changes: 12 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
lint-pr-title:
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
25 changes: 25 additions & 0 deletions .github/workflows/manual-publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
workflow_dispatch:

name: Publish Docs
jobs:
build-publish:
runs-on: ubuntu-latest
permissions:
id-token: write # Needed if using OIDC to get release secrets.
contents: write # Needed in this case to write github pages.
steps:
- uses: actions/checkout@v4

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1
name: Assume aws role
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}

- name: Build and Test
uses: ./.github/actions/ci

- name: Publish Documentation
uses: ./.github/actions/publish-docs
with:
token: ${{secrets.GITHUB_TOKEN}}
Loading

0 comments on commit 7103634

Please sign in to comment.