Skip to content

Commit

Permalink
chore: Add github CI and release-please.
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion committed Feb 15, 2024
1 parent f6ba29d commit b2d384b
Show file tree
Hide file tree
Showing 15 changed files with 273 additions and 90 deletions.
84 changes: 0 additions & 84 deletions .circleci/config.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use a step like this to build documentation.
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@v3
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
19 changes: 19 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Publish to github pages or to a different documentation system.

name: Publish Documentation
description: 'Publish the documentation to X'
inputs:
token:
description: 'Token to use for publishing.'
required: true

runs:
using: composite
steps:
# This publishes a 'docs' folder to github pages. If you need to publish another way,
# then you can just script it here, or call a script.
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.1
name: 'Publish to Github pages'
with:
docs_path: docs
github_token: { token } # For the shared action the token should be a GITHUB_TOKEN
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: [ 'rlamb/github-ci-and-release' ]
paths-ignore:
- '**.md' # Do not need to run CI for markdown changes.
pull_request:
branches: [ 'rlamb/github-ci-and-release' ]
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
21 changes: 21 additions & 0 deletions .github/workflows/manual-publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
workflow_dispatch:

name: Publish Documentation
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
- 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}}
43 changes: 43 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Package
on:
workflow_dispatch:
inputs:
prerelease:
description: 'Is this a prerelease.' # use this to control publish tag, for instance NPM wouldn't set latest.
type: boolean
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true

jobs:
build-publish:
runs-on: ubuntu-latest
# Needed to get tokens during publishing.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- id: build-and-test
# Build using the same steps from CI.
name: Build and Test
uses: ./.github/actions/ci

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.0
name: 'Get your token!'
with:
# The AWS_ROLE_ARN needs added as a var to your repo.
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
# This example uses the node release token, it will get set into the NODE_AUTH_TOKEN
# environment variable. The action readme contains more information.
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'

- id: publish
name: Publish Package
uses: ./.github/actions/publish
with:
token: "Put your release secret or github token here."
prerelease: ${{ inputs.prerelease }}
dry_run: ${{ inputs.dry_run }}
54 changes: 54 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Run Release Please

on:
push:
branches:
- main

jobs:
release-package:
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
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
token: ${{secrets.GITHUB_TOKEN}}
default-branch: main

- uses: actions/checkout@v4
if: ${{ steps.release.outputs.releases_created }}
with:
fetch-depth: 0 # If you only need the current version remove this line.

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.0
if: ${{ steps.release.outputs.releases_created }}
name: 'Get your token!'
with:
# The AWS_ROLE_ARN needs added as a var to your repo.
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
# This example uses the node release token, it will get set into the NODE_AUTH_TOKEN
# environment variable. The action readme contains more information.
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'

- uses: ./.github/actions/ci
if: ${{ steps.release.outputs.releases_created }}

- uses: ./.github/actions/publish
if: ${{ steps.release.outputs.releases_created }}
with:
# If publishing somewhere else, then get the token from SSM. If you need both github,
# and another token, then add more tokens to the composite action. Could be $NODE_AUTH_TOKEN
# from the release-secrets action earlier in this workflow.
token: ${{secrets.GITHUB_TOKEN}}

- uses: ./.github/actions/publish-docs
if: ${{ steps.release.outputs.releases_created }}
with:
# If publishing somewhere else, then get the token from SSM. If you need both github,
# and another token, then add more tokens to the composite action.
token: ${{secrets.GITHUB_TOKEN}}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ project.lock.json

*.snk
*.p12

_site/
docs/
api/
38 changes: 38 additions & 0 deletions docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"metadata": [
{
"src": [
{
"src": "./src",
"files": [
"**/*.csproj"
]
}
],
"dest": "./api"
}
],
"build": {
"content": [
{
"files": [
"**/*.{md,yml}"
],
"exclude": [
"docs/**"
]
}
],
"output": "docs",
"template": [
"default",
"modern"
],
"globalMetadata": {
"_appName": "Launchdarkly Logging Adapter For NLog",
"_appTitle": "Launchdarkly Logging Adapter For NLog",
"_enableSearch": true,
"pdf": false
}
}
}
File renamed without changes.
10 changes: 5 additions & 5 deletions src/LaunchDarkly.Logging.NLog/LaunchDarkly.Logging.NLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
SDKs which do not consider "net5.0" to be a valid target framework that can be
referenced in a project file.
-->
<BuildFrameworks Condition="'$(BUILDFRAMEWORKS)' == ''">netstandard2.0;net452</BuildFrameworks>
<BuildFrameworks Condition="'$(BUILDFRAMEWORKS)' == ''">netstandard2.0;net462</BuildFrameworks>
<TargetFrameworks>$(BUILDFRAMEWORKS)</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>LaunchDarkly.Logging.NLog</AssemblyName>
Expand All @@ -31,10 +31,10 @@
<PackageReference Include="NLog" Version="[4.5.0,6.0.0)" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<AssemblyOriginatorKeyFile>../../LaunchDarkly.Logging.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<!-- <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">-->
<!-- <AssemblyOriginatorKeyFile>../../LaunchDarkly.Logging.snk</AssemblyOriginatorKeyFile>-->
<!-- <SignAssembly>true</SignAssembly>-->
<!-- </PropertyGroup>-->

<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\LaunchDarkly.Logging.NLog.xml</DocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TestFramework Condition="'$(TESTFRAMEWORK)' == ''">netcoreapp2.1;net5.0</TestFramework>
<TestFramework Condition="'$(TESTFRAMEWORK)' == ''">net7.0</TestFramework>
<TargetFrameworks>$(TESTFRAMEWORK)</TargetFrameworks>
<AssemblyName>LaunchDarkly.Logging.NLog.Tests</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: API
href: api/

0 comments on commit b2d384b

Please sign in to comment.