Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add release-please support. #103

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Documentation
description: 'Build Documentation.'

runs:
using: composite
steps:
- name: Setup dotnet build tools
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0
- name: Install docfx
shell: bash
run: dotnet tool update -g docfx

# Note: in the docfx.json file, the 'Configuration' property is set to Debug so that we don't require
# signing to happen just to build docs.
- name: Build docs
shell: bash
run: |
docfx metadata
docfx build
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:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true
token:
description: 'Token to use for publishing.'
required: true

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/[email protected]
if: ${{ inputs.dry_run == 'false' }}
name: 'Publish to Github pages'
with:
docs_path: docs
github_token: ${{ inputs.token }}
- name: Dry Run Publish
if: ${{ inputs.dry_run == 'true' }}
shell: bash
run: |
echo "This is a dry run and docs are not being published."
50 changes: 50 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Package
description: '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
outputs:
hashes:
description: sha256sum hashes of built artifacts
value: ${{ steps.hash.outputs.hashes }}

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

- name: Create Nuget Package
shell: bash
run: |
dotnet restore ./src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj
dotnet pack --no-build --output nupkgs --configuration Release ./src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.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: Hash nuget packages
id: hash
if: ${{ inputs.dry_run == 'false' }}
shell: bash
run: |
echo "hashes=$(sha256sum ./nupkgs/*.nupkg ./nupkgs/*.snupkg | base64 -w0)" >> "$GITHUB_OUTPUT"

- 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: 9.0

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

- name: Build
shell: bash
run: dotnet build /p:Configuration=Release ./src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ jobs:
- run: dotnet build src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj

- run: dotnet test test/LaunchDarkly.EventSource.Tests/LaunchDarkly.EventSource.Tests.csproj

- name: build docs
uses: ./.github/actions/build-docs
86 changes: 86 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Publish Package

on:
workflow_dispatch:
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true
tag:
description: 'Tag for provenance. For a dry run the value does not matter.'
type: string
required: true

workflow_call:
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true
tag:
description: 'Tag for provenance'
type: string
required: true

jobs:
publish:
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: actions/checkout@v4

- uses: launchdarkly/gh-actions/actions/[email protected]
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.EventSource.snk = LaunchDarkly.EventSource.snk'


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

- name: Build Documentation
uses: ./.github/actions/build-docs

- name: Sign DLLs
uses: launchdarkly/gh-actions/actions/[email protected]
with:
build_configuration_path: ./src/LaunchDarkly.EventSource/bin/Release
dll_name: LaunchDarkly.EventSource.Microsoft.dll

- name: Publish Nupkg
id: publish
uses: ./.github/actions/publish
with:
dry_run: ${{ inputs.dry_run }}

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

provenance:
permissions:
actions: read
id-token: write
contents: write
if: ${{ inputs.dry_run == 'false' }}
needs: ['publish']
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.publish.outputs.hashes }}"
upload-assets: true
upload-tag-name: ${{ inputs.tag }}
provenance-name: ${{ format('LaunchDarkly.EventSource-{0}_provenance.intoto.jsonl', inputs.tag) }}
36 changes: 36 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Please

on:
push:
branches:
- main

jobs:
release-please:
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
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: googleapis/release-please-action@v4
id: release
with:
token: ${{secrets.GITHUB_TOKEN}}
default-branch: main

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

# Click-Once directory
publish

# Others
[Bb]in
[Oo]bj
Expand Down Expand Up @@ -179,3 +176,6 @@ project.lock.json

*.snk
*.p12

api/
docs/
24 changes: 0 additions & 24 deletions .ldrelease/config.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "5.1.0"
}
48 changes: 48 additions & 0 deletions docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"metadata": [
{
"src": [
{
"src": "./src",
"files": [
"**/*.csproj",
"**/bin/**/**LaunchDarkly**.dll"
]
}
],
"dest": "./api",
"properties" : {
"Configuration": "Debug"
}
}
],
"build": {
"content": [
{
"files": [
"**/*.{md,yml}"
],
"exclude": [
"docs/**"
]
}
],
"resource": [
{
"files": [
"images/**"
]
}
],
"output": "docs",
"template": [
"default"
],
"globalMetadata": {
"_appName": "LaunchDarkly EventSource for .NET",
"_appTitle": "LaunchDarkly EventSource for .NET",
"_enableSearch": true,
"pdf": false
}
}
}
10 changes: 10 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"packages": {
".": {
"release-type": "simple",
"bootstrap-sha": "42cd339937a4affdbe94ab0d49694a86eb85c75f",
"include-v-in-tag": false,
"include-component-in-tag": false
}
}
}
Loading