From fdd5a44f4803fc6026b24e665a91b7415e92cca2 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:58:55 -0800 Subject: [PATCH] chore: Change order of checkout versus secret access. Remove bad git ignore. Add publish action. (#27) The git ignore file prevented the publish action from being committed. The checkout was deleting the SNK. --- .github/actions/publish/action.yml | 50 ++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 3 +- .gitignore | 3 -- 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 .github/actions/publish/action.yml diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000..8d659cf --- /dev/null +++ b/.github/actions/publish/action.yml @@ -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.Logging.Microsoft/LaunchDarkly.Logging.Microsoft.csproj + dotnet pack --no-build --output nupkgs --configuration Release ./src/LaunchDarkly.Logging.Microsoft/LaunchDarkly.Logging.Microsoft.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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3cbbe4c..a5a33fc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,6 +32,8 @@ jobs: pull-requests: write steps: + - uses: actions/checkout@v4 + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0 name: Get secrets with: @@ -44,7 +46,6 @@ jobs: /production/common/releasing/nuget/api_key = NUGET_API_KEY' s3_path_pairs: 'launchdarkly-releaser/dotnet/LaunchDarkly.Logging.snk = LaunchDarkly.Logging.snk' - - uses: actions/checkout@v4 - name: Build Release uses: ./.github/actions/release-build diff --git a/.gitignore b/.gitignore index 45ca060..dbcceea 100644 --- a/.gitignore +++ b/.gitignore @@ -54,9 +54,6 @@ DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html -# Click-Once directory -publish - # Others [Bb]in [Oo]bj