Skip to content

Commit

Permalink
Reusable workflow for pack
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrzajac committed Oct 21, 2023
1 parent b6fbfba commit f8ac4e8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 36 deletions.
43 changes: 7 additions & 36 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,46 +140,17 @@ jobs:
target-framework: ${{ matrix.target-framework }}
pack:
needs: [init, build-and-test]
runs-on: windows-latest # We are using windows instead of ubuntu becaus it provides support for net472 & net48.
timeout-minutes: 15
env:
Version: ${{ needs.init.outputs.Version }}
strategy:
matrix:
package-module: ${{ fromJSON(needs.init.outputs.matrix) }}
if: ${{ needs.init.outputs.matrix != '' }}
steps:
- name: 📥 checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🖊️ materialize signing key
id: signing-key
uses: ./.github/actions/materialize-signing-key
with:
signing-key-value: ${{ secrets.SIGNING_KEY }}
- name: 💾 cache nuget packages
uses: actions/cache@v3
with:
path: ${{ env.NUGET_PACKAGES }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: 📦 pack
if: ${{ startsWith(matrix.package-module, 'Auto' ) }}
run: dotnet pack ./src/${{ env.Namespace }}.${{ matrix.package-module }}
env:
CI: true
StrongNameKey: ${{ secrets.SIGNING_KEY }}
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}
- name: 🔼 upload packages
if: ${{ startsWith(matrix.package-module, 'Auto' ) }}
uses: actions/upload-artifact@v3
with:
name: packages
path: |
./src/**/*.nupkg
./src/**/*.snupkg
uses: ./.github/workflows/pack.yml
with:
version: ${{ needs.init.outputs.Version }}
package-module: ${{ matrix.package-module }}
namespace: Objectivity.AutoFixture.XUnit2
secrets:
signing-key-value: ${{ secrets.SIGNING_KEY }}
publish:
runs-on: ubuntu-latest
continue-on-error: true
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/pack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Prepare NuGet package
on:
workflow_call:
inputs:
version:
description: Assembly and package version
required: true
type: string
package-module:
description: Name of the module
required: true
type: string
namespace:
description: Name of the module namespace
required: true
type: string
secrets:
signing-key-value:
required: true
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
Version: ${{ inputs.version }}
jobs:
pack:
runs-on: windows-latest # We are using windows instead of ubuntu becaus it provides support for net472 & net48.
timeout-minutes: 15
if: ${{ startsWith(inputs.package-module, 'Auto' ) }}
steps:
- name: 📥 checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🖊️ materialize signing key
id: signing-key
uses: ./.github/actions/materialize-signing-key
with:
signing-key-value: ${{ secrets.signing-key-value }}
- name: 💾 cache nuget packages
uses: actions/cache@v3
with:
path: ${{ env.NUGET_PACKAGES }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: 📦 pack
run: dotnet pack ./src/${{ inputs.namespace }}.${{ inputs.package-module }}
env:
CI: true
StrongNameKey: ${{ secrets.signing-key-value }}
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}
- name: 🔼 upload packages
uses: actions/upload-artifact@v3
with:
name: packages
path: |
./src/**/*.nupkg
./src/**/*.snupkg

0 comments on commit f8ac4e8

Please sign in to comment.