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: cleaning up github actions paths, fixing publish docs params #8

Merged
merged 17 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
53 changes: 53 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Setup Package Environment
description: Based on the provided package name, this action will map and set up the necessary environment variables
inputs:
pkg_name:
description: 'The package this will setup the environment for'
required: true

runs:
using: composite
steps:
- name: Setup env variables based on pkg_name
env:
PACKAGE_NAME: ${{ inputs.pkg_name }}
run: |
local WORKSPACE_PATH=''
tanderson-ld marked this conversation as resolved.
Show resolved Hide resolved
local PROJECT_FILE=''
local BUILD_OUTPUT_PATH=''
local BUILD_OUTPUT_DLL_NAME=''
local TEST_PROJECT_FILE=''
local CONTRACT_TEST_PROJECT_FILE=''
local CONTRACT_TEST_DLL_FILE=''

if [[ $PACKAGE_NAME == 'LaunchDarkly.ClientSdk' ]]; then
WORKSPACE_PATH='pkgs/sdk/client'
tanderson-ld marked this conversation as resolved.
Show resolved Hide resolved
PROJECT_FILE='pkgs/sdk/client/src/LaunchDarkly.ClientSdk.csproj'
TEST_PROJECT_FILE='pkgs/sdk/client/test/LaunchDarkly.ClientSdk.Tests.csproj'
BUILD_OUTPUT_PATH='pkgs/sdk/client/src/LaunchDarkly.ClientSdk/bin/Release/'
BUILD_OUTPUT_DLL_NAME='LaunchDarkly.ClientSdk.dll'
CONTRACT_TEST_PROJECT_FILE='pkgs/sdk/client/contract-tests/TestService.csproj'
CONTRACT_TEST_DLL_FILE='pkgs/sdk/server/contract-tests/bin/debug/net6.0/ContractTestService.dll'

elif [[ $PACKAGE_NAME == 'LaunchDarkly.ServerSdk' ]]; then
WORKSPACE_PATH='pkgs/sdk/server'
PROJECT_FILE='pkgs/sdk/server/src/LaunchDarkly.ServerSdk.csproj'
TEST_PROJECT_FILE='pkgs/sdk/server/test/LaunchDarkly.ServerSdk.Tests.csproj'
BUILD_OUTPUT_PATH='pkgs/sdk/server/src/bin/Release/'
BUILD_OUTPUT_DLL_NAME='LaunchDarkly.ServerSdk.dll'

elif [[ $PACKAGE_NAME == 'LaunchDarkly.ServerSdk.Telemetry' ]]; then
WORKSPACE_PATH='pkgs/telemetry'
PROJECT_FILE='pkgs/telemetry/src/LaunchDarkly.ServerSdk.Telemetry.csproj'
TEST_PROJECT_FILE='pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj'
BUILD_OUTPUT_PATH='pkgs/telemetry/src/bin/Release/'
BUILD_OUTPUT_DLL_NAME='LaunchDarkly.ServerSdk.Telemetry.dll'
fi

echo "WORKSPACE_PATH=$WORKSPACE_PATH" >> $GITHUB_ENV
echo "PROJECT_FILE=$PROJECT_FILE" >> $GITHUB_ENV
echo "TEST_PROJECT_FILE=$TEST_PROJECT_FILE" >> $GITHUB_ENV
echo "BUILD_OUTPUT_PATH=$BUILD_OUTPUT_PATH" >> $GITHUB_ENV
echo "BUILD_OUTPUT_DLL_NAME=$BUILD_OUTPUT_DLL_NAME" >> $GITHUB_ENV
echo "CONTRACT_TEST_PROJECT_FILE=$CONTRACT_TEST_PROJECT_FILE" >> $GITHUB_ENV
echo "CONTRACT_TEST_DLL_NAME=$CONTRACT_TEST_DLL_NAME" >> $GITHUB_ENV
58 changes: 16 additions & 42 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
options:
- LaunchDarkly.ServerSdk
- LaunchDarkly.ServerSdk.Telemetry
- LaunchDarkly.ClientSdk
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
Expand All @@ -23,68 +24,41 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Using macos-latest since mac is the lowest common denominator for platforms that supports all the client SDK target frameworks.

permissions:
id-token: write
contents: write
outputs:
server-sdk-hashes: ${{ steps.server-sdk-release.outputs.hashes }}
telemetry-hashes: ${{ steps.telemetry-release.outputs.hashes }}
full-release-hashes: ${{ steps.full-release.outputs.hashes }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Commonizing

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/full-release
id: server-sdk-release
if: ${{ inputs.pkg_name == 'LaunchDarkly.ServerSdk' }}

- uses: ./.github/actions/setup-env
with:
workspace_path: 'pkgs/sdk/server'
project_file: 'pkgs/sdk/server/src/LaunchDarkly.ServerSdk.csproj'
test_project_file: 'pkgs/sdk/server/test/LaunchDarkly.ServerSdk.Tests.csproj'
build_output_path: 'pkgs/sdk/server/src/bin/Release/'
dll_name: 'LaunchDarkly.ServerSdk.dll'
dry_run: ${{ inputs.dry_run }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}
workspace_path: ${{ inputs.pkg_name }}

- uses: ./.github/actions/full-release
id: telemetry-release
if: ${{ inputs.pkg_name == 'LaunchDarkly.ServerSdk.Telemetry' }}
id: full-release
with:
workspace_path: 'pkgs/telemetry'
project_file: 'pkgs/telemetry/src/LaunchDarkly.ServerSdk.Telemetry.csproj'
test_project_file: 'pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj'
build_output_path: 'pkgs/telemetry/src/bin/Release/'
dll_name: 'LaunchDarkly.ServerSdk.Telemetry.dll'
workspace_path: ${{ env.WORKSPACE_PATH }}
project_file: ${{ env.PROJECT_FILE }}
build_output_path: ${{ env.BUILD_OUTPUT_PATH }}
test_project_file: ${{ env.TEST_PROJECT_FILE }}
dll_name: ${{ env.BUILD_OUTPUT_DLL_NAME }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: the setup env action helps compartmentalize all the path strings

dry_run: ${{ inputs.dry_run }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}

release-sdk-server-provenance:
needs: ['build']
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
if: |
(inputs.generate_provenance == 'Generate' || (inputs.generate_provenance == 'Default' && github.ref_name == 'main')) &&
inputs.pkg_name == 'LaunchDarkly.ServerSdk'
with:
base64-subjects: "${{ needs.build.outputs.server-sdk-hashes }}"
upload-assets: true
provenance-name: ${{ 'LaunchDarkly.ServerSdk_provenance.intoto.jsonl' }}


release-telemetry-server-provenance:
release-provenance:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commonizing

needs: ['build']
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
if: |
(inputs.generate_provenance == 'Generate' || (inputs.generate_provenance == 'Default' && github.ref_name == 'main')) &&
inputs.pkg_name == 'LaunchDarkly.ServerSdk.Telemetry'
(inputs.generate_provenance == 'Generate' || (inputs.generate_provenance == 'Default' && github.ref_name == 'main'))
with:
base64-subjects: "${{ needs.build.outputs.telemetry-hashes }}"
base64-subjects: "${{ needs.build.outputs.full-release-hashes }}"
upload-assets: true
provenance-name: ${{ 'LaunchDarkly.ServerSdk.Telemetry_provenance.intoto.jsonl' }}
provenance-name: ${{inputs.pkg_name}}_provenance.intoto.jsonl
47 changes: 17 additions & 30 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,44 @@
on:
workflow_dispatch:
inputs:
workspace_path:
description: 'Path to the workspace being released.'
pkg_name:
description: 'The package to publish'
required: true
type: string
project_file:
description: 'Path to the project file.'
required: true
type: string
test_project_file:
description: 'Path to the test project file. If provided, run unit tests, otherwise skip them.'
required: false
type: string
workflow_call:
inputs:
workspace_path:
description: 'Path to the workspace being released.'
required: true
type: string
project_file:
description: 'Path to the project file.'
required: true
type: string
test_project_file:
description: 'Path to the test project file. If provided, run unit tests, otherwise skip them.'
required: false
type: string
type: choice
options:
- LaunchDarkly.ClientSdk
- LaunchDarkly.ServerSdk
- LaunchDarkly.ServerSdk.Telemetry
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: This gives a dropdown when triggering the action, a better user experience with less chance for errors.


name: Publish Docs
jobs:
build-publish:
runs-on: ubuntu-latest
runs-on: macos-latest
permissions:
contents: write # Needed in this case to write github pages.
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-env
with:
workspace_path: ${{ inputs.pkg_name }}

- id: build
name: Build and Test SDK
uses: ./.github/actions/ci
with:
project_file: ${{ inputs.project_file }}
test_project_file: ${{ inputs.test_project_file }}
project_file: ${{ env.PROJECT_FILE }}
test_project_file: ${{ env.TEST_PROJECT_FILE }}

- id: build-docs
name: Build Documentation
uses: ./.github/actions/build-docs
with:
workspace_path: ${{ inputs.workspace_path }}
workspace_path: ${{ env.WORKSPACE_PATH }}

- id: publish-docs
name: Publish Documentation
uses: ./.github/actions/publish-docs
with:
workspace_path: ${{ inputs.workspace_path }}
workspace_path: ${{ env.WORKSPACE_PATH }}
token: ${{secrets.GITHUB_TOKEN}}
95 changes: 69 additions & 26 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:

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

outputs:
package-sdk-server-released: ${{ steps.release.outputs['pkgs/sdk/server--release_created'] }}
package-sdk-server-tag_name: ${{ steps.release.outputs['pkgs/sdk/server--tag_name'] }}
package-sdk-server-telemetry-released: ${{ steps.release.outputs['pkgs/telemetry--release_created'] }}
package-sdk-server-telemetry-tag_name: ${{ steps.release.outputs['pkgs/telemetry--tag_name'] }}
package-sdk-client-released: ${{ steps.release.outputs['pkgs/sdk/client--release_created'] }}
package-sdk-client-tag_name: ${{ steps.release.outputs['pkgs/sdk/client--tag_name'] }}
tag_name: ${{ steps.release.outputs.tag_name }}

steps:
Expand All @@ -24,7 +26,7 @@ jobs:
target-branch: ${{ github.ref_name }}

release-sdk-server:
runs-on: ubuntu-latest
runs-on: macos-latest
needs: release-please
permissions:
id-token: write
Expand All @@ -35,55 +37,94 @@ jobs:
hashes: ${{ steps.full-release.outputs.hashes }}
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-env
tanderson-ld marked this conversation as resolved.
Show resolved Hide resolved
with:
workspace_path: LaunchDarkly.ServerSdk

- uses: ./.github/actions/full-release
id: full-release
with:
workspace_path: 'pkgs/sdk/server'
project_file: 'pkgs/sdk/server/src/LaunchDarkly.ServerSdk.csproj'
test_project_file: 'pkgs/sdk/server/test/LaunchDarkly.ServerSdk.Tests.csproj'
build_output_path: 'pkgs/sdk/server/src/bin/Release/'
dll_name: 'LaunchDarkly.ServerSdk.dll'
dry_run: false
workspace_path: ${{ env.WORKSPACE_PATH }}
project_file: ${{ env.PROJECT_FILE }}
build_output_path: ${{ env.BUILD_OUTPUT_PATH }}
test_project_file: ${{ env.TEST_PROJECT_FILE }}
dll_name: ${{ env.BUILD_OUTPUT_DLL_NAME }}
dry_run: ${{ inputs.dry_run }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}

release-sdk-server-provenance:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Moved provenance tasks to the bottom for organization. Made the diff weird.

needs: ['release-please', 'release-sdk-server']
release-telemetry:
runs-on: macos-latest
needs: release-please
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
with:
base64-subjects: "${{ needs.release-sdk-server.outputs.hashes }}"
upload-assets: true
upload-tag-name: ${{ needs.release-please.outputs.package-sdk-server-tag_name }}
provenance-name: ${{ format('LaunchDarkly.ServerSdk-{0}_provenance.intoto.jsonl', needs.release-please.outputs.package-sdk-server-tag_name) }}
pull-requests: write
if: ${{ needs.release-please.outputs.package-sdk-server-telemetry-released == 'true'}}
outputs:
hashes: ${{ steps.full-release.outputs.hashes }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-env
with:
workspace_path: LaunchDarkly.ServerSdk.Telemetry

release-telemetry:
runs-on: ubuntu-latest
- uses: ./.github/actions/full-release
id: full-release
with:
workspace_path: ${{ env.WORKSPACE_PATH }}
project_file: ${{ env.PROJECT_FILE }}
build_output_path: ${{ env.BUILD_OUTPUT_PATH }}
test_project_file: ${{ env.TEST_PROJECT_FILE }}
dll_name: ${{ env.BUILD_OUTPUT_DLL_NAME }}
dry_run: ${{ inputs.dry_run }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}

release-sdk-client:
runs-on: macos-latest
needs: release-please
permissions:
id-token: write
contents: write
pull-requests: write
if: ${{ needs.release-please.outputs.package-sdk-server-telemetry-released == 'true'}}
if: ${{ needs.release-please.outputs.package-sdk-client-released == 'true'}}
outputs:
hashes: ${{ steps.full-release.outputs.hashes }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-env
with:
workspace_path: LaunchDarkly.ClientSdk

- uses: ./.github/actions/full-release
id: full-release
with:
workspace_path: 'pkgs/telemetry'
project_file: 'pkgs/telemetry/src/LaunchDarkly.ServerSdk.Telemetry.csproj'
test_project_file: 'pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj'
build_output_path: 'pkgs/telemetry/src/bin/Release/'
dll_name: 'LaunchDarkly.ServerSdk.Telemetry.dll'
dry_run: false
workspace_path: ${{ env.WORKSPACE_PATH }}
project_file: ${{ env.PROJECT_FILE }}
build_output_path: ${{ env.BUILD_OUTPUT_PATH }}
test_project_file: ${{ env.TEST_PROJECT_FILE }}
dll_name: ${{ env.BUILD_OUTPUT_DLL_NAME }}
dry_run: ${{ inputs.dry_run }}
aws_role: ${{ vars.AWS_ROLE_ARN }}
token: ${{ secrets.GITHUB_TOKEN }}

# TODO: refactor provenance
release-sdk-server-provenance:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Moved provenance tasks to the bottom for organization. Made the diff weird.

needs: ['release-please', 'release-sdk-server']
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
with:
base64-subjects: "${{ needs.release-sdk-server.outputs.hashes }}"
upload-assets: true
upload-tag-name: ${{ needs.release-please.outputs.package-sdk-server-tag_name }}
provenance-name: ${{ format('LaunchDarkly.ServerSdk-{0}_provenance.intoto.jsonl', needs.release-please.outputs.package-sdk-server-tag_name) }}


release-telemetry-provenance:
needs: ['release-please', 'release-telemetry']
permissions:
Expand All @@ -96,3 +137,5 @@ jobs:
upload-assets: true
upload-tag-name: ${{ needs.release-please.outputs.package-sdk-server-telemetry-tag_name }}
provenance-name: ${{ format('LaunchDarkly.ServerSdk.Telemetry-{0}_provenance.intoto.jsonl', needs.release-please.outputs.package-sdk-server-telemetry-tag_name) }}

# TODO: add client provenance
Loading