From 7cf8d3db2a42245186c3d1e24bfc04943e5b77ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:17:23 +0100 Subject: [PATCH 1/8] Added github workflow for building, testing and packing --- .github/workflows/main.yml | 187 +++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..ea209687 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,187 @@ +name: main + +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: + - published + +env: + # Setting these variables allows .NET CLI to use rich color codes in console output + TERM: xterm + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true + # Skip boilerplate output + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + # Determine version + version: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Determine stable version + id: stable-version + if: ${{ github.event_name == 'release' }} + run: | + if ! [[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z].*)?$ ]]; then + echo "Invalid version: ${{ github.event.release.tag_name }}" + exit 1 + fi + + echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + + - name: Determine prerelease version + id: pre-version + if: ${{ github.event_name != 'release' }} + run: | + hash="${{ github.event.pull_request.head.sha || github.sha }}" + echo "version=0.0.0-ci-${hash:0:7}" >> $GITHUB_OUTPUT + + outputs: + version: ${{ steps.stable-version.outputs.version || steps.pre-version.outputs.version }} + + # Check formatting +# format: +# runs-on: ubuntu-latest +# permissions: +# contents: read + +# steps: +# - name: Checkout +# uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + +# - name: Install .NET +# uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + +# - name: Validate format +# run: dotnet format --verify-no-changes + + # Run tests + test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + # Windows runners don't support Linux Docker containers (needed for tests), + # so we currently cannot run tests on Windows. + # - windows-latest + + runs-on: ${{ matrix.os }} + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + - name: Run restore + run: dotnet restore + + - name: Run build + run: > + dotnet build + --no-restore + --configuration Release + + - name: Run tests + run: > + dotnet test + --no-restore + --no-build + --configuration Release + ${{ runner.os == 'Windows' && '-p:IncludeNetCoreAppTargets=false' || '' }} + --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" + -- + RunConfiguration.CollectSourceInformation=true + + # Pack the output into NuGet packages + pack: + needs: version + runs-on: ubuntu-latest + permissions: + actions: write + contents: read + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + - name: Run restore + run: dotnet restore + + - name: Run build + run: > + dotnet build + --no-restore + --configuration Release + -p:ContinuousIntegrationBuild=true + + - name: Run pack + run: > + dotnet pack + -p:Version=${{ needs.version.outputs.version }} + -p:ContinuousIntegrationBuild=true + --no-restore + --no-build + --configuration Release + + - name: Upload artifacts + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: packages + path: "**/*.nupkg" + + # Deploy the NuGet packages to the corresponding registries + deploy: + needs: + # Technically, it's not required for the format job to succeed for us to push the package, + # so we may consider removing it as a prerequisite here. + # - format + - test + - pack + + runs-on: ubuntu-latest + permissions: + actions: read + packages: write + + steps: + - name: Download artifacts + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + with: + name: packages + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + # Publish to GitHub package registry every time, whether it's a prerelease + # version or a stable release version. + - name: Publish packages (GitHub Registry) + run: > + dotnet nuget push **/*.nupkg + --source https://nuget.pkg.github.com/passwordless-lib/index.json + --api-key ${{ secrets.GITHUB_TOKEN }} + + # Only publish to NuGet on stable releases + # - name: Publish packages (NuGet Registry) + # if: ${{ github.event_name == 'release' }} + # run: > + # dotnet nuget push **/*.nupkg + # --source https://api.nuget.org/v3/index.json + # --api-key ${{ secrets.nuget_api_key }} \ No newline at end of file From 1a1c61d7e1c0401ee3521c968922f2b0e2c75797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:21:30 +0100 Subject: [PATCH 2/8] switch to master --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea209687..04166556 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,12 +1,12 @@ -name: main +name: master on: push: branches: - - main + - master pull_request: branches: - - main + - master release: types: - published From d25c9cab4385e392c37ffe6104789224484b1a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:26:32 +0100 Subject: [PATCH 3/8] Adde manual runner alternative --- .github/workflows/main.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 04166556..e9cd66b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,13 @@ name: master on: + workflow_dispatch: + inputs: + force_version: + description: "The version to use" + required: true + default: "0.0.0-test" + type: string push: branches: - master @@ -47,7 +54,7 @@ jobs: echo "version=0.0.0-ci-${hash:0:7}" >> $GITHUB_OUTPUT outputs: - version: ${{ steps.stable-version.outputs.version || steps.pre-version.outputs.version }} + version: ${{ github.event.inputs.force_version || steps.stable-version.outputs.version || steps.pre-version.outputs.version }} # Check formatting # format: From 2d19a751e8be53318ccbfa393b9cb5123b073047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:33:10 +0100 Subject: [PATCH 4/8] change logger --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e9cd66b1..ceb1e754 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,7 +110,7 @@ jobs: --no-build --configuration Release ${{ runner.os == 'Windows' && '-p:IncludeNetCoreAppTargets=false' || '' }} - --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" + --logger "trx;LogFileName=pw-test-results.trx -- RunConfiguration.CollectSourceInformation=true From 7cee5f3884af83ca0b84432f1fcd8abcae8afd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:35:18 +0100 Subject: [PATCH 5/8] fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ceb1e754..4624c749 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,7 +110,7 @@ jobs: --no-build --configuration Release ${{ runner.os == 'Windows' && '-p:IncludeNetCoreAppTargets=false' || '' }} - --logger "trx;LogFileName=pw-test-results.trx + --logger "trx;LogFileName=pw-test-results.trx" -- RunConfiguration.CollectSourceInformation=true From 10768928ffff739cd946e2df98c7417b50977d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:49:07 +0100 Subject: [PATCH 6/8] Don't pack automatically --- .github/workflows/main.yml | 3 ++- Src/Directory.Build.props | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4624c749..f07919ea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -138,7 +138,8 @@ jobs: --no-restore --configuration Release -p:ContinuousIntegrationBuild=true - + -p:Version=${{ needs.version.outputs.version }} + - name: Run pack run: > dotnet pack diff --git a/Src/Directory.Build.props b/Src/Directory.Build.props index 94c54bc0..00c23c19 100644 --- a/Src/Directory.Build.props +++ b/Src/Directory.Build.props @@ -14,6 +14,6 @@ true - true + false \ No newline at end of file From d7ebd2162e72c61994a839326e1add1b54999bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:52:59 +0100 Subject: [PATCH 7/8] added readme to dirProps --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index a0a197bd..fdcaef59 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,6 +11,7 @@ Initial release https://github.com/passwordless-lib/fido2-net-lib MIT + README.md From ca80bfdb8ea2a8ed51b633fe18639d2ee33c9577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Fri, 17 Nov 2023 17:55:44 +0100 Subject: [PATCH 8/8] Remove readme --- Directory.Build.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index fdcaef59..a0a197bd 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,6 @@ Initial release https://github.com/passwordless-lib/fido2-net-lib MIT - README.md