Skip to content

Commit

Permalink
chore: Add github CI and release-please. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Feb 21, 2024
1 parent 912e244 commit 1ec959e
Show file tree
Hide file tree
Showing 20 changed files with 343 additions and 105 deletions.
84 changes: 0 additions & 84 deletions .circleci/config.yml

This file was deleted.

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

runs:
using: composite
steps:
- name: Build Documentation
shell: bash
run: |
dotnet tool update -g docfx
docfx metadata
docfx build
39 changes: 39 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This is a composite to allow sharing these steps into other workflows.
# For instance it could be used by regular CI as well as the release process.

name: CI Workflow
description: 'Shared CI workflow.'
inputs:
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
required: false
default: 'true'

runs:
using: composite
steps:
- name: Setup dotnet build tools
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0

- name: Restore dotnet dependencies
shell: bash
id: restore
run: dotnet restore

- name: Build
shell: bash
id: build
run: dotnet build

- name: Run Tests
if: steps.build.outcome == 'success' && inputs.run_tests == 'true'
shell: bash
run: dotnet test

# We build documentation during CI to ensure it can always build prior to a
# release.
- name: Build documentation
if: steps.build.outcome == 'success'
uses: ./.github/actions/build-docs
15 changes: 15 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Publish Documentation
description: 'Publish the documentation to X'
inputs:
token:
description: 'Token to use for publishing.'
required: true

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.1
name: 'Publish to Github pages'
with:
docs_path: docs
github_token: ${{ inputs.token }} # For the shared action the token should be a GITHUB_TOKEN
34 changes: 34 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish
description: 'Dotnet Logging Adapter NLog action that packs DLLs into unsigned Nuget package and publishes to Nuget.'
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true

runs:
using: composite
steps:
- name: Create Nuget Package
shell: bash
run: |
dotnet restore
dotnet pack --no-build --output nupkgs --configuration Release src/LaunchDarkly.Logging.NLog/LaunchDarkly.Logging.NLog.csproj
- name: Publish Package
if: ${{ inputs.dry_run == 'false' }}
shell: bash
run: |
for pkg in $(find ./nupkgs -name '*.nupkg' -o -name '*.snupkg'); do
echo "publishing ${pkg}"
dotnet nuget push "${pkg}" --api-key ${{ env.NUGET_API_KEY }} --source https://www.nuget.org
echo "published ${pkg}"
done
- name: Dry Run Publish
if: ${{ inputs.dry_run == 'true' }}
shell: bash
run: |
echo "This is a dry run and packages are not being published."
for pkg in $(find ./nupkgs -name '*.nupkg' -o -name '*.snupkg'); do
echo "detected package ${pkg}"
done
18 changes: 18 additions & 0 deletions .github/actions/release-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Build
description: 'Build in Release Configuration'

runs:
using: composite
steps:
- name: Setup dotnet build tools
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0

- name: Restore Packages
shell: bash
run: dotnet restore

- name: Build
shell: bash
run: dotnet build /p:Configuration=Release
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run CI
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:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # If you only need the current version keep this.

- uses: ./.github/actions/ci
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
20 changes: 20 additions & 0 deletions .github/workflows/manual-publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
workflow_dispatch:

name: Publish Documentation
jobs:
build-publish:
runs-on: ubuntu-latest
permissions:
contents: write # Needed in this case to write github pages.
steps:
- uses: actions/checkout@v4
- id: build
name: Build and Test
uses: ./.github/actions/ci

- id: publish
name: Publish Documentation
uses: ./.github/actions/publish-docs
with:
token: ${{secrets.GITHUB_TOKEN}}
70 changes: 70 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Publish Package
on:
workflow_dispatch:
inputs:
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
type: boolean
default: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true
workflow_call:
inputs:
run_tests:
description: 'If true, run unit tests, otherwise skip them.'
required: false
type: boolean
default: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true

jobs:
# Building is done on mac runner due to xcode build dependencies
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # If you only need the current version keep this

- uses: actions/checkout@v4
with:
fetch-depth: 0 # If you only need the current version keep this

- name: CI check
uses: ./.github/actions/ci
with:
run_tests: ${{ inputs.run_tests }}

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.1.0
name: Get secrets
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/digicert/host = DIGICERT_HOST,
/production/common/releasing/digicert/api_key = DIGICERT_API_KEY,
/production/common/releasing/digicert/client_cert_file_b64 = DIGICERT_CLIENT_CERT_FILE_B64,
/production/common/releasing/digicert/client_cert_password = DIGICERT_CLIENT_CERT_PASSWORD,
/production/common/releasing/digicert/code_signing_cert_sha1_hash = DIGICERT_CODE_SIGNING_CERT_SHA1_HASH,
/production/common/releasing/nuget/api_key = NUGET_API_KEY'
s3_path_pairs: 'launchdarkly-releaser/dotnet/LaunchDarkly.Logging.snk = LaunchDarkly.Logging.snk'

- name: Release Build
uses: ./.github/actions/release-build

- name: Sign DLLs
uses: launchdarkly/gh-actions/actions/sign-dlls@sign-dlls-v1.0.0
with:
build_configuration_path: "src/LaunchDarkly.Logging.NLog/bin/Release/"
dll_name: 'LaunchDarkly.Logging.NLog.dll'

- name: Publish Nupkg
uses: ./.github/actions/publish
with:
dry_run: ${{ inputs.dry_run }}
33 changes: 33 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Release Please

on:
push:
branches:
- main

jobs:
release-please:
runs-on: ubuntu-latest

permissions:
id-token: write # Needed if using OIDC to get release secrets.
contents: write # Contents and pull-requests are for release-please to make releases.
pull-requests: write

outputs:
releases_created: ${{ steps.release.outputs.releases_created }}

steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
target-branch: ${{ github.ref_name }}

call-workflow-publish:
needs: release-please
uses: ./.github/workflows/publish.yml
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
with:
run_tests: true
dry_run: false
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Others
[Bb]in
[Oo]bj
Expand All @@ -80,3 +77,8 @@ project.lock.json

*.snk
*.p12

_site/
docs/
api/
nupkgs/
Loading

0 comments on commit 1ec959e

Please sign in to comment.