Skip to content

Commit 5fb7944

Browse files
authored
chore: Add release-please support. (#103)
1 parent 51dd143 commit 5fb7944

File tree

12 files changed

+302
-27
lines changed

12 files changed

+302
-27
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build Documentation
2+
description: 'Build Documentation.'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup dotnet build tools
8+
uses: actions/setup-dotnet@v4
9+
with:
10+
dotnet-version: 9.0
11+
- name: Install docfx
12+
shell: bash
13+
run: dotnet tool update -g docfx
14+
15+
# Note: in the docfx.json file, the 'Configuration' property is set to Debug so that we don't require
16+
# signing to happen just to build docs.
17+
- name: Build docs
18+
shell: bash
19+
run: |
20+
docfx metadata
21+
docfx build
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish Documentation
2+
description: 'Publish the documentation to Github pages'
3+
inputs:
4+
dry_run:
5+
description: 'Is this a dry run. If so no package will be published.'
6+
required: true
7+
token:
8+
description: 'Token to use for publishing.'
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.2
15+
if: ${{ inputs.dry_run == 'false' }}
16+
name: 'Publish to Github pages'
17+
with:
18+
docs_path: docs
19+
github_token: ${{ inputs.token }}
20+
- name: Dry Run Publish
21+
if: ${{ inputs.dry_run == 'true' }}
22+
shell: bash
23+
run: |
24+
echo "This is a dry run and docs are not being published."

.github/actions/publish/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Package
2+
description: 'Packs DLLs into unsigned Nuget package and publishes to Nuget.'
3+
inputs:
4+
dry_run:
5+
description: 'Is this a dry run. If so no package will be published.'
6+
required: true
7+
outputs:
8+
hashes:
9+
description: sha256sum hashes of built artifacts
10+
value: ${{ steps.hash.outputs.hashes }}
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Setup dotnet build tools
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: 9.0
19+
20+
- name: Create Nuget Package
21+
shell: bash
22+
run: |
23+
dotnet restore ./src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj
24+
dotnet pack --no-build --output nupkgs --configuration Release ./src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj
25+
26+
- name: Publish Package
27+
if: ${{ inputs.dry_run == 'false' }}
28+
shell: bash
29+
run: |
30+
for pkg in $(find ./nupkgs -name '*.nupkg' -o -name '*.snupkg'); do
31+
echo "publishing ${pkg}"
32+
dotnet nuget push "${pkg}" --api-key ${{ env.NUGET_API_KEY }} --source https://www.nuget.org
33+
echo "published ${pkg}"
34+
done
35+
36+
- name: Hash nuget packages
37+
id: hash
38+
if: ${{ inputs.dry_run == 'false' }}
39+
shell: bash
40+
run: |
41+
echo "hashes=$(sha256sum ./nupkgs/*.nupkg ./nupkgs/*.snupkg | base64 -w0)" >> "$GITHUB_OUTPUT"
42+
43+
- name: Dry Run Publish
44+
if: ${{ inputs.dry_run == 'true' }}
45+
shell: bash
46+
run: |
47+
echo "This is a dry run and packages are not being published."
48+
for pkg in $(find ./nupkgs -name '*.nupkg' -o -name '*.snupkg'); do
49+
echo "detected package ${pkg}"
50+
done
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release Build
2+
description: 'Build in Release Configuration'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup dotnet build tools
8+
uses: actions/setup-dotnet@v4
9+
with:
10+
dotnet-version: 9.0
11+
12+
- name: Restore Packages
13+
shell: bash
14+
run: dotnet restore
15+
16+
- name: Build
17+
shell: bash
18+
run: dotnet build /p:Configuration=Release ./src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jobs:
3535
- run: dotnet build src/LaunchDarkly.EventSource/LaunchDarkly.EventSource.csproj
3636

3737
- run: dotnet test test/LaunchDarkly.EventSource.Tests/LaunchDarkly.EventSource.Tests.csproj
38+
39+
- name: build docs
40+
uses: ./.github/actions/build-docs

.github/workflows/publish.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dry_run:
7+
description: 'Is this a dry run. If so no package will be published.'
8+
type: boolean
9+
required: true
10+
tag:
11+
description: 'Tag for provenance. For a dry run the value does not matter.'
12+
type: string
13+
required: true
14+
15+
workflow_call:
16+
inputs:
17+
dry_run:
18+
description: 'Is this a dry run. If so no package will be published.'
19+
type: boolean
20+
required: true
21+
tag:
22+
description: 'Tag for provenance'
23+
type: string
24+
required: true
25+
26+
jobs:
27+
publish:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
id-token: write # Needed if using OIDC to get release secrets.
31+
contents: write # Contents and pull-requests are for release-please to make releases.
32+
pull-requests: write
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
38+
name: Get secrets
39+
with:
40+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
41+
ssm_parameter_pairs: '/production/common/releasing/digicert/host = DIGICERT_HOST,
42+
/production/common/releasing/digicert/api_key = DIGICERT_API_KEY,
43+
/production/common/releasing/digicert/client_cert_file_b64 = DIGICERT_CLIENT_CERT_FILE_B64,
44+
/production/common/releasing/digicert/client_cert_password = DIGICERT_CLIENT_CERT_PASSWORD,
45+
/production/common/releasing/digicert/code_signing_cert_sha1_hash = DIGICERT_CODE_SIGNING_CERT_SHA1_HASH,
46+
/production/common/releasing/nuget/api_key = NUGET_API_KEY'
47+
s3_path_pairs: 'launchdarkly-releaser/dotnet/LaunchDarkly.EventSource.snk = LaunchDarkly.EventSource.snk'
48+
49+
50+
- name: Build Release
51+
uses: ./.github/actions/release-build
52+
53+
- name: Build Documentation
54+
uses: ./.github/actions/build-docs
55+
56+
- name: Sign DLLs
57+
uses: launchdarkly/gh-actions/actions/sign-dlls@sign-dlls-v1.0.0
58+
with:
59+
build_configuration_path: ./src/LaunchDarkly.EventSource/bin/Release
60+
dll_name: LaunchDarkly.EventSource.Microsoft.dll
61+
62+
- name: Publish Nupkg
63+
id: publish
64+
uses: ./.github/actions/publish
65+
with:
66+
dry_run: ${{ inputs.dry_run }}
67+
68+
- name: Publish Documentation
69+
uses: ./.github/actions/publish-docs
70+
with:
71+
token: ${{ secrets.GITHUB_TOKEN }}
72+
dry_run: ${{ inputs.dry_run }}
73+
74+
provenance:
75+
permissions:
76+
actions: read
77+
id-token: write
78+
contents: write
79+
if: ${{ inputs.dry_run == 'false' }}
80+
needs: ['publish']
81+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
82+
with:
83+
base64-subjects: "${{ needs.publish.outputs.hashes }}"
84+
upload-assets: true
85+
upload-tag-name: ${{ inputs.tag }}
86+
provenance-name: ${{ format('LaunchDarkly.EventSource-{0}_provenance.intoto.jsonl', inputs.tag) }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
outputs:
11+
releases_created: ${{ steps.release.outputs.releases_created }}
12+
tag_name: ${{ steps.release.outputs.tag_name }}
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write # Needed if using OIDC to get release secrets.
16+
contents: write # Contents and pull-requests are for release-please to make releases.
17+
pull-requests: write
18+
19+
steps:
20+
- uses: googleapis/release-please-action@v4
21+
id: release
22+
with:
23+
token: ${{secrets.GITHUB_TOKEN}}
24+
default-branch: main
25+
26+
ci:
27+
needs: ['release-please']
28+
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
29+
uses: ./.github/workflows/ci.yml
30+
publish:
31+
needs: ['release-please', 'ci']
32+
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
33+
uses: ./.github/workflows/publish.yml
34+
with:
35+
dry_run: false
36+
tag: ${{ needs.release-please.outputs.tag_name }}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ DocProject/Help/*.hhp
9797
DocProject/Help/Html2
9898
DocProject/Help/html
9999

100-
# Click-Once directory
101-
publish
102-
103100
# Others
104101
[Bb]in
105102
[Oo]bj
@@ -179,3 +176,6 @@ project.lock.json
179176

180177
*.snk
181178
*.p12
179+
180+
api/
181+
docs/

.ldrelease/config.yml

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

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "5.1.0"
3+
}

0 commit comments

Comments
 (0)