From 61ca9142b0d87915ff0c7d4c6f3bfcf96c95a50f Mon Sep 17 00:00:00 2001 From: Piotr Zajac Date: Fri, 13 Oct 2023 16:06:43 +0200 Subject: [PATCH] Materialize signing key step as reusable action --- .../actions/materialize-signing-key.yml | 22 +++++++++++++++++++ .github/workflows/cicd.yml | 12 +++------- .github/workflows/test-mutations.yml | 10 ++------- 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/actions/materialize-signing-key.yml diff --git a/.github/workflows/actions/materialize-signing-key.yml b/.github/workflows/actions/materialize-signing-key.yml new file mode 100644 index 00000000..5eff1b4b --- /dev/null +++ b/.github/workflows/actions/materialize-signing-key.yml @@ -0,0 +1,22 @@ +name: Materialize signing key +description: Materializes key to sign assemblies +outputs: + file-path: + description: "signing key file path" + value: ${{ steps.signing-key.outputs.PATH }} +env: + StrongNameKeyName: key.snk +defaults: + run: + shell: pwsh +runs: + using: "composite" + steps: + - name: ๐Ÿ–Š๏ธ materialize signing key + id: signing-key + run: | + $path = [IO.Path]::Combine("${{ github.workspace }}","src","${{ env.StrongNameKeyName }}") + [IO.File]::WriteAllBytes($path, [Convert]::FromBase64String("$env:StrongNameKey")) + "PATH=$path" >> $env:GITHUB_OUTPUT + env: + StrongNameKey: ${{ secrets.SIGNING_KEY }} diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 13fd2684..39031b79 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -39,7 +39,6 @@ env: DOTNET_CLI_TELEMETRY_OPTOUT: true Configuration: Release Namespace: Objectivity.AutoFixture.XUnit2 - StrongNameKeyName: key.snk CoverageDirectory: ${{ github.workspace }}\src\opencover defaults: @@ -93,18 +92,13 @@ jobs: fetch-depth: 0 - name: ๐Ÿ–Š๏ธ materialize signing key id: signing-key - run: | - $path = [IO.Path]::Combine("${{ github.workspace }}","src","${{ env.StrongNameKeyName }}") - [IO.File]::WriteAllBytes($path, [Convert]::FromBase64String("$env:StrongNameKey")) - "PATH=$path" >> $env:GITHUB_OUTPUT - env: - StrongNameKey: ${{ secrets.SIGNING_KEY }} + uses: actions/materialize-signing-key@reusable-actions - name: ๐Ÿ—๏ธ build run: dotnet build ./src/${{ env.Namespace }}.${{ matrix.package_module }}.sln env: CI: true StrongNameKey: ${{ secrets.SIGNING_KEY }} - StrongNameKeyPath: ${{ steps.signing-key.outputs.PATH }} + StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }} - name: ๐Ÿงช test Core in net7.0 & collect coverage id: core-code-coverage run: | @@ -143,7 +137,7 @@ jobs: env: CI: true StrongNameKey: ${{ secrets.SIGNING_KEY }} - StrongNameKeyPath: ${{ steps.signing-key.outputs.PATH }} + StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }} - name: ๐Ÿ”ผ upload packages uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/test-mutations.yml b/.github/workflows/test-mutations.yml index c170d1bd..f57f6888 100644 --- a/.github/workflows/test-mutations.yml +++ b/.github/workflows/test-mutations.yml @@ -19,7 +19,6 @@ env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true Configuration: Release - StrongNameKeyName: key.snk defaults: run: @@ -35,12 +34,7 @@ jobs: fetch-depth: 0 - name: ๐Ÿ–Š๏ธ materialize signing key id: signing-key - run: | - $path = [IO.Path]::Combine("${{ github.workspace }}","src","${{ env.StrongNameKeyName }}") - [IO.File]::WriteAllBytes($path, [Convert]::FromBase64String("$env:StrongNameKey")) - "PATH=$path" >> $env:GITHUB_OUTPUT - env: - StrongNameKey: ${{ secrets.SIGNING_KEY }} + uses: actions/materialize-signing-key@reusable-actions - name: ๐Ÿ’พ install stryker.net run: | dotnet new tool-manifest @@ -52,5 +46,5 @@ jobs: env: CI: true StrongNameKey: ${{ secrets.SIGNING_KEY }} - StrongNameKeyPath: ${{ steps.signing-key.outputs.PATH }} + StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}