Skip to content

Commit 7f59d87

Browse files
authored
chore: Release please and github CI support. (#20)
1 parent 86eb1e2 commit 7f59d87

File tree

15 files changed

+237
-148
lines changed

15 files changed

+237
-148
lines changed

.circleci/config.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

.github/actions/ci/action.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI Workflow
2+
description: 'Shared CI workflow.'
3+
inputs:
4+
run_tests:
5+
description: 'If true, run unit tests, otherwise skip them.'
6+
required: false
7+
default: 'true'
8+
java_version:
9+
description: 'The Java version to use.'
10+
required: true
11+
java_distribution:
12+
description: 'The Java distribution to use.'
13+
required: false
14+
default: 'temurin'
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: ${{ inputs.java_distribution }}
23+
java-version: ${{ inputs.java_version }}
24+
25+
- name: Restore dependencies
26+
shell: bash
27+
id: restore
28+
run: ./gradlew dependencies
29+
30+
- name: Build
31+
shell: bash
32+
id: build
33+
run: ./gradlew jar
34+
35+
- name: Run Tests
36+
if: steps.build.outcome == 'success' && inputs.run_tests == 'true'
37+
shell: bash
38+
run: ./gradlew test

.github/actions/publish/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish Package
2+
description: 'Publish the package to Sonatype'
3+
inputs:
4+
code_signing_keyring:
5+
description: 'The path of the code signing keyring.'
6+
required: true
7+
prerelease:
8+
description: 'Is this a prerelease. If so then it will be published to the staging repository only.'
9+
required: true
10+
dry_run:
11+
description: 'Is this a dry run. If so no package will be published.'
12+
required: true
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Publish Library
18+
shell: bash
19+
if: ${{ inputs.dry_run == 'false' }}
20+
env:
21+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
22+
run: source $GITHUB_ACTION_PATH/publish.sh
23+
24+
- name: Dry Run Publish Library
25+
shell: bash
26+
if: ${{ inputs.dry_run == 'true' }}
27+
run: echo "Dry run. Not publishing."

.github/actions/publish/publish.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
echo "Publishing to Sonatype"
6+
if [ "${LD_RELEASE_IS_PRERELEASE}" == "true" ]; then
7+
echo "PRERELEASE"
8+
./gradlew publishToSonatype -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PossrhUsername="${SONATYPE_USER_NAME}" -PossrhPassword="${SONATYPE_PASSWORD}" || {
9+
echo "Gradle publish/release faile" >&2
10+
exit 1
11+
}
12+
else
13+
echo "RELEASE"
14+
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository || {
15+
echo "Gradle publish/release failed" >&2
16+
exit 1
17+
}
18+
fi

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and Test
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [ 'main' ]
6+
paths-ignore:
7+
- '**.md' # Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [ 'main' ]
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
ci-build:
15+
strategy:
16+
matrix:
17+
java_version: ['11', '19']
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: ./.github/actions/ci
23+
with:
24+
java_version: ${{ matrix.java_version }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Lint PR title
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
lint-pr-title:
12+
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Package
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
run_tests:
6+
description: 'If true, run unit tests, otherwise skip them.'
7+
type: boolean
8+
default: true
9+
dry_run:
10+
description: 'Is this a dry run. If so no package will be published.'
11+
type: boolean
12+
required: true
13+
prerelease:
14+
description: 'If true, then this is a prerelease and should be published to the staging repository only.'
15+
type: boolean
16+
required: true
17+
workflow_call:
18+
inputs:
19+
run_tests:
20+
description: 'If true, run unit tests, otherwise skip them.'
21+
required: false
22+
type: boolean
23+
default: true
24+
dry_run:
25+
description: 'Is this a dry run. If so no package will be published.'
26+
type: boolean
27+
required: true
28+
prerelease:
29+
description: 'If true, then this is a prerelease and should be published to the staging repository only.'
30+
type: boolean
31+
required: true
32+
33+
jobs:
34+
build-and-publish:
35+
runs-on: ubuntu-latest
36+
permissions:
37+
id-token: write
38+
contents: read
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: CI check
43+
uses: ./.github/actions/ci
44+
with:
45+
run_tests: ${{ inputs.run_tests }}
46+
47+
- uses: launchdarkly/gh-actions/actions/[email protected]
48+
name: Get secrets
49+
with:
50+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
51+
ssm_parameter_pairs: '/production/common/releasing/sonatype/username = SONATYPE_USER_NAME,
52+
/production/common/releasing/sonatype/password = SONATYPE_PASSWORD
53+
/production/common/releasing/java/keyId = SIGNING_KEY_ID'
54+
s3_path_pairs: 'launchdarkly-releaser/java/code-signing-keyring.gpg = code-signing-keyring.gpg'
55+
56+
- name: Publish
57+
uses: ./.github/actions/publish
58+
with:
59+
dry_run: ${{ inputs.dry_run }}
60+
prerelease: ${{ inputs.prerelease }}
61+
code_signing_keyring: 'code-signing-keyring.gpg'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
id-token: write # Needed for OIDC to get release secrets.
14+
contents: write # Contents and pull-requests are for release-please to make releases.
15+
pull-requests: write
16+
17+
outputs:
18+
releases_created: ${{ steps.release.outputs.releases_created }}
19+
20+
steps:
21+
- uses: google-github-actions/release-please-action@v4
22+
id: release
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
target-branch: ${{ github.ref_name }}
26+
27+
call-workflow-publish:
28+
needs: release-please
29+
uses: ./.github/workflows/publish.yml
30+
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
31+
with:
32+
run_tests: true
33+
dry_run: false
34+
prerelease: false

.ldrelease/config.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.ldrelease/publish.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)