From 7ade87a87d7271c3549ab1da585b8b2206a2e9b3 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:30:49 +0300 Subject: [PATCH 01/15] Consolidate workflows --- .github/workflows/main.yml | 167 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 41 -------- .github/workflows/workflow.yml | 121 ------------------------ 3 files changed, 167 insertions(+), 162 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..73bd99a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,167 @@ +name: main + +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: + - published + +jobs: + build: + runs-on: ${{ matrix.os }} + permissions: + actions: write + contents: read + + env: + TERM: xterm + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + + strategy: + fail-fast: false + max-parallel: 3 + matrix: + os: [ ubuntu-latest, windows-latest ] + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + - name: Run build + run: dotnet build --configuration Release + + - name: Upload artifacts + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: build + path: . + + test: + needs: build + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + + env: + TERM: xterm + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + + steps: + - name: Download artifacts + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + with: + name: build + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + - name: Validate format + run: dotnet format --no-restore --verify-no-changes + + - name: Run tests + run: > + dotnet test + --no-build + --no-restore + --configuration Release + --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" + -- + RunConfiguration.CollectSourceInformation=true + + pack: + needs: test + runs-on: ubuntu-latest + permissions: + actions: write + contents: read + + env: + TERM: xterm + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + + steps: + - name: Download artifacts + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + with: + name: build + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + - name: Set version + id: set-version + if: ${{ github.event_name != 'release' }} + run: | + ref="${{ github.head_ref || github.ref_name }}" + ref_clean="${ref/\//-}" + version_suffix="ci-${ref_clean}-${{ github.run_id }}" + echo "version-suffix=${version_suffix}" >> $GITHUB_OUT + + - name: Create packages + run: > + dotnet pack + --no-build + --configuration Release + ${{ env.steps.set-version.outputs.version-suffix && format('--version-suffix {0}', env.steps.set-version.outputs.version-suffix) || '' }} + + - name: Upload artifacts + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: packages + path: "**/*.nupkg" + + deploy: + needs: pack + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + packages: write + + env: + TERM: xterm + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + + 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 + + - name: Publish packages (GitHub Registry) + run: > + dotnet nuget push **/*.nupkg + --source https://nuget.pkg.github.com/passwordless/index.json + --api-key ${{ env.GITHUB_TOKEN }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish packages (NuGet Registry) + 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 48b6ad0..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Release to NuGet - -on: - release: - types: [published] - -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - name: Checkout - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - - name: Setup dotnet - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - - - name: Build - run: dotnet build --configuration Release - - - name: Test - run: > - dotnet test - --no-build - --configuration Release - --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" - -- - RunConfiguration.CollectSourceInformation=true - - - name: Pack nugets - run: > - dotnet pack - --configuration Release - --no-build - --output . - - - name: Push to NuGet - run: > - dotnet nuget push *.nupkg - --source https://api.nuget.org/v3/index.json - --api-key ${{secrets.nuget_api_key}} diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml deleted file mode 100644 index cfc9bff..0000000 --- a/.github/workflows/workflow.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: Build,Format,Test,Publish - -on: - push: - branches: [main] - pull_request: - branches: [ main ] - -permissions: - id-token: write - contents: read - checks: write - packages: write - -jobs: - build-dotnet: - runs-on: ubuntu-latest - # strategy: - # matrix: - # dotnet-version: [ '3.1.x', '6.0.x' ] - outputs: - clean_name: ${{steps.clean_branch_name.outputs.CLEAN_BRANCH_NAME}} - - steps: - - name: Checkout - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - - name: Setup dotnet - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - # with: - # dotnet-version: ${{ matrix.dotnet-version }} - - # You can test your matrix by printing the current dotnet version - - name: Display dotnet version - run: dotnet --version - - - name: Install dependencies - run: dotnet restore --locked-mode - - - name: Build - run: > - dotnet build - --no-restore - --framework net6.0 - --configuration Release - --verbosity minimal - - - name: Check Format - run: dotnet format --verify-no-changes --no-restore - - - name: Test with the dotnet CLI - run: > - dotnet test - --no-build - --no-restore - --framework net6.0 - --configuration Release - --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" - -- - RunConfiguration.CollectSourceInformation=true - - - id: clean_branch_name - name: Clean Branch Name - run: echo "CLEAN_BRANCH_NAME=${BRANCH_NAME/\//-}" >> "$GITHUB_OUTPUT" - env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - - build-framework: - runs-on: windows-latest - needs: build-dotnet - steps: - - name: Checkout - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - # - name: Setup dotnet - # uses: setup msbuild? - - - name: Display dotnet version - run: | - dotnet --version - dotnet --info - - - name: Install dependencies - run: dotnet restore --locked-mode - - - name: Build - # Don't specify a framework here so we build both .NET and .NET Framework so we can pack both - run: > - dotnet build - --no-restore - --configuration Release - --verbosity minimal - - # Don't bother running formatting for this build - - - name: Test with the dotnet CLI - # We will have already ran the tests on ubuntu, so only do .NET Framework ones here - run: > - dotnet test - --no-build - --no-restore - --framework net462 - --configuration Release - --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" - -- - RunConfiguration.CollectSourceInformation=true - - - name: Pack NuGet Packages - run: > - dotnet pack - --no-build - --configuration Release - --version-suffix "ci-${{ needs.build-dotnet.outputs.clean_name }}-${{ github.run_id }}" - - - name: Publish NuGet Packages - run: > - dotnet nuget push **/*.nupkg - --source https://nuget.pkg.github.com/passwordless/index.json - --api-key ${{env.GITHUB_TOKEN}} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9d8419c80a96009ed0e39d6f21b0e27ef3d870f4 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:36:16 +0300 Subject: [PATCH 02/15] Clean up --- .github/workflows/main.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73bd99a..6404371 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,6 @@ jobs: runs-on: ubuntu-latest permissions: actions: read - contents: read env: TERM: xterm @@ -88,7 +87,6 @@ jobs: runs-on: ubuntu-latest permissions: actions: write - contents: read env: TERM: xterm @@ -133,7 +131,6 @@ jobs: runs-on: ubuntu-latest permissions: actions: read - contents: read packages: write env: @@ -156,9 +153,7 @@ jobs: run: > dotnet nuget push **/*.nupkg --source https://nuget.pkg.github.com/passwordless/index.json - --api-key ${{ env.GITHUB_TOKEN }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + --api-key ${{ secrets.GITHUB_TOKEN }} - name: Publish packages (NuGet Registry) run: > From cdab161ff39e86bb0fb214c2a67f7b973be76471 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:48:57 +0300 Subject: [PATCH 03/15] Simplify workflow --- .github/workflows/main.yml | 99 +++++++++++++------------------------- 1 file changed, 33 insertions(+), 66 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6404371..91627d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,19 +11,36 @@ on: types: - published +env: + TERM: xterm + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + jobs: build: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest permissions: - actions: write contents: read - env: - TERM: xterm - DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Install .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + + - name: Run build + run: dotnet build --configuration Release + + - name: Validate format + run: dotnet format --no-restore --verify-no-changes + + test: + runs-on: ${{ matrix.os }} + permissions: + contents: read strategy: fail-fast: false @@ -38,68 +55,23 @@ jobs: - name: Install .NET uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - - name: Run build - run: dotnet build --configuration Release - - - name: Upload artifacts - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 - with: - name: build - path: . - - test: - needs: build - runs-on: ubuntu-latest - permissions: - actions: read - - env: - TERM: xterm - DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - - steps: - - name: Download artifacts - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 - with: - name: build - - - name: Install .NET - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - - - name: Validate format - run: dotnet format --no-restore --verify-no-changes - - name: Run tests run: > dotnet test - --no-build - --no-restore --configuration Release --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" -- RunConfiguration.CollectSourceInformation=true - + pack: - needs: test runs-on: ubuntu-latest permissions: actions: write - - env: - TERM: xterm - DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true + contents: read steps: - - name: Download artifacts - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 - with: - name: build + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - name: Install .NET uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 @@ -116,7 +88,6 @@ jobs: - name: Create packages run: > dotnet pack - --no-build --configuration Release ${{ env.steps.set-version.outputs.version-suffix && format('--version-suffix {0}', env.steps.set-version.outputs.version-suffix) || '' }} @@ -127,19 +98,15 @@ jobs: path: "**/*.nupkg" deploy: - needs: pack + needs: + - build + - test + - pack runs-on: ubuntu-latest permissions: actions: read packages: write - env: - TERM: xterm - DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - steps: - name: Download artifacts uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 From a45e85b7b395dcbe8f00404153cf74507ecc6b6a Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:50:13 +0300 Subject: [PATCH 04/15] Clean --- .github/workflows/main.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91627d3..556fd33 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - + steps: - name: Checkout uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 @@ -36,25 +36,25 @@ jobs: - name: Validate format run: dotnet format --no-restore --verify-no-changes - + test: runs-on: ${{ matrix.os }} permissions: contents: read - + strategy: fail-fast: false max-parallel: 3 matrix: os: [ ubuntu-latest, windows-latest ] - + steps: - name: Checkout uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - + - name: Install .NET uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - + - name: Run tests run: > dotnet test @@ -62,13 +62,13 @@ jobs: --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" -- RunConfiguration.CollectSourceInformation=true - + pack: runs-on: ubuntu-latest permissions: actions: write contents: read - + steps: - name: Checkout uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 @@ -96,7 +96,7 @@ jobs: with: name: packages path: "**/*.nupkg" - + deploy: needs: - build @@ -121,7 +121,7 @@ jobs: dotnet nuget push **/*.nupkg --source https://nuget.pkg.github.com/passwordless/index.json --api-key ${{ secrets.GITHUB_TOKEN }} - + - name: Publish packages (NuGet Registry) run: > dotnet nuget push **/*.nupkg From af2b640dbd91c6186c059f201fd3cc9da439efb0 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:56:54 +0300 Subject: [PATCH 05/15] asd --- .github/workflows/main.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 556fd33..0a5258f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ env: DOTNET_CLI_TELEMETRY_OPTOUT: true jobs: - build: + format: runs-on: ubuntu-latest permissions: contents: read @@ -31,11 +31,8 @@ jobs: - name: Install .NET uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - - name: Run build - run: dotnet build --configuration Release - - name: Validate format - run: dotnet format --no-restore --verify-no-changes + run: dotnet format --verify-no-changes test: runs-on: ${{ matrix.os }} @@ -99,7 +96,7 @@ jobs: deploy: needs: - - build + - format - test - pack runs-on: ubuntu-latest From 05503be2974e37d4272ef06389b7baaa9627fb36 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:58:57 +0300 Subject: [PATCH 06/15] zxc --- .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 0a5258f..40c6ca2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,7 +80,7 @@ jobs: ref="${{ github.head_ref || github.ref_name }}" ref_clean="${ref/\//-}" version_suffix="ci-${ref_clean}-${{ github.run_id }}" - echo "version-suffix=${version_suffix}" >> $GITHUB_OUT + echo "version-suffix=${version_suffix}" >> $GITHUB_OUTPUT - name: Create packages run: > From 5c619ff5b1980a8e53b23a2365fbcf12057ebf68 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:02:14 +0300 Subject: [PATCH 07/15] only push to nuget on release --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 40c6ca2..948d05a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -120,7 +120,8 @@ jobs: --api-key ${{ secrets.GITHUB_TOKEN }} - 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 + --api-key ${{ secrets.nuget_api_key }} \ No newline at end of file From 3f690818a69bc65a7303bb4744ba6ed5db6f9ba8 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:47:51 +0300 Subject: [PATCH 08/15] Fix prerelease versioning --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 948d05a..0cb1233 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,20 +73,20 @@ jobs: - name: Install .NET uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 - - name: Set version - id: set-version + - name: Generate prerelease version + id: prerelease-version if: ${{ github.event_name != 'release' }} run: | ref="${{ github.head_ref || github.ref_name }}" ref_clean="${ref/\//-}" - version_suffix="ci-${ref_clean}-${{ github.run_id }}" - echo "version-suffix=${version_suffix}" >> $GITHUB_OUTPUT + suffix="ci-${ref_clean}-${{ github.run_id }}" + echo "suffix=${suffix}" >> $GITHUB_OUTPUT - name: Create packages run: > dotnet pack --configuration Release - ${{ env.steps.set-version.outputs.version-suffix && format('--version-suffix {0}', env.steps.set-version.outputs.version-suffix) || '' }} + ${{ steps.prerelease-version.outputs.suffix && format('--version-suffix {0}', steps.prerelease-version.outputs.suffix) || '' }} - name: Upload artifacts uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 From bf8574dc43e74b2f6e43e7db9f18039228b932b5 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:20:38 +0300 Subject: [PATCH 09/15] Add comments, as per Anders' request --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0cb1233..f66368b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,12 +12,28 @@ on: - 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 +# Note that as much as we'd love to avoid repetitive work, splitting the pipeline in separate jobs +# makes it very difficult to share artifacts between them. Even if we succeed, we'll still end up +# pushing and pulling gigabytes worth of data, which makes the jobs so much slower that we might as +# well just repeat the checkout-restore-build steps instead. +# Having a setup that involves separate jobs gives us significant benefits, on the other hand, namely: +# - Most of them can run in parallel, which reduces the overall execution time significantly, despite +# the repetitive work. +# - We can catch more issues this way, for example if the formatting job fails, we can still see the +# the test results too. +# - If one of the jobs fails due to reasons unrelated to our code (e.g. NuGet server is down), we get +# the option to rerun only that job, saving time. +# - It's easier to understand what each job does (and later, read its output) because the scope is much +# more narrow. + jobs: format: runs-on: ubuntu-latest @@ -73,6 +89,8 @@ jobs: - name: Install .NET uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 + # When triggered by `push` or `pull_request` events, generate a prerelease version + # for the package, so as to clearly indicate that it's not a stabel version release. - name: Generate prerelease version id: prerelease-version if: ${{ github.event_name != 'release' }} @@ -96,6 +114,8 @@ jobs: 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 @@ -113,12 +133,15 @@ jobs: - 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/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: > From dc31c81d9931cbc29c5dcb72e44a7e9ea56dad99 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:23:25 +0300 Subject: [PATCH 10/15] Better comments --- .github/workflows/main.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f66368b..54c71c2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,21 +20,23 @@ env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true -# Note that as much as we'd love to avoid repetitive work, splitting the pipeline in separate jobs +# Note that as much as we'd love to avoid repetitive work, splitting the pipeline into separate jobs # makes it very difficult to share artifacts between them. Even if we succeed, we'll still end up # pushing and pulling gigabytes worth of data, which makes the jobs so much slower that we might as # well just repeat the checkout-restore-build steps instead. + # Having a setup that involves separate jobs gives us significant benefits, on the other hand, namely: -# - Most of them can run in parallel, which reduces the overall execution time significantly, despite -# the repetitive work. +# - Most of the jobs can run in parallel, which reduces the overall execution time significantly, +# despite the repetitive work. # - We can catch more issues this way, for example if the formatting job fails, we can still see the # the test results too. # - If one of the jobs fails due to reasons unrelated to our code (e.g. NuGet server is down), we get -# the option to rerun only that job, saving time. +# the option to rerun only that job, saving us time. # - It's easier to understand what each job does (and later, read its output) because the scope is much # more narrow. jobs: + # Check formatting format: runs-on: ubuntu-latest permissions: @@ -50,6 +52,7 @@ jobs: - name: Validate format run: dotnet format --verify-no-changes + # Run tests test: runs-on: ${{ matrix.os }} permissions: @@ -76,6 +79,7 @@ jobs: -- RunConfiguration.CollectSourceInformation=true + # Pack the output into NuGet packages pack: runs-on: ubuntu-latest permissions: @@ -90,7 +94,7 @@ jobs: uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3 # When triggered by `push` or `pull_request` events, generate a prerelease version - # for the package, so as to clearly indicate that it's not a stabel version release. + # for the package, so as to clearly indicate that it's not a stable version release. - name: Generate prerelease version id: prerelease-version if: ${{ github.event_name != 'release' }} @@ -112,6 +116,7 @@ jobs: 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, From af03d677ee6adfdf8a664f9a5347c46e90c33752 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:28:25 +0300 Subject: [PATCH 11/15] Add one more point --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54c71c2..388bb3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,6 +34,8 @@ env: # the option to rerun only that job, saving us time. # - It's easier to understand what each job does (and later, read its output) because the scope is much # more narrow. +# - We can set permissions on a more granular (per-job) level, which allows us to expose only a few select +# steps to more sensitive access scopes. jobs: # Check formatting From 209b4976edc3f54c360be73fa689ac221b6e043d Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:10:46 +0300 Subject: [PATCH 12/15] Split out build stages --- .github/workflows/main.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 388bb3d..ebfbc3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,9 +73,17 @@ jobs: - 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 --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" -- @@ -95,6 +103,12 @@ jobs: - 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 + # When triggered by `push` or `pull_request` events, generate a prerelease version # for the package, so as to clearly indicate that it's not a stable version release. - name: Generate prerelease version @@ -109,6 +123,8 @@ jobs: - name: Create packages run: > dotnet pack + --no-restore + --no-build --configuration Release ${{ steps.prerelease-version.outputs.suffix && format('--version-suffix {0}', steps.prerelease-version.outputs.suffix) || '' }} From 60633a629826545b77060dce31c110b75a07e644 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:05:37 +0300 Subject: [PATCH 13/15] Test only against .NET legacy on Windows --- .github/workflows/main.yml | 1 + tests/Passwordless.Tests/Passwordless.Tests.csproj | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebfbc3f..2110b69 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,6 +85,7 @@ jobs: --no-restore --no-build --configuration Release + ${{ runner.os == 'Windows' && '-p:IncludeNetCoreAppTargets=false' || '' }} --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" -- RunConfiguration.CollectSourceInformation=true diff --git a/tests/Passwordless.Tests/Passwordless.Tests.csproj b/tests/Passwordless.Tests/Passwordless.Tests.csproj index 5d042a6..d6552ed 100644 --- a/tests/Passwordless.Tests/Passwordless.Tests.csproj +++ b/tests/Passwordless.Tests/Passwordless.Tests.csproj @@ -1,11 +1,15 @@ + - net6.0;net7.0 - $(TargetFrameworks);net462 - $(TargetFrameworks);$(CurrentPreviewTfm) - false - true + true + $([MSBuild]::IsOsPlatform('Windows')) + + + + $(TargetFrameworks);net6.0;net7.0 + $(TargetFrameworks);net462 + $(TargetFrameworks);$(CurrentPreviewTfm) From 970d86b7a46a0744accc4e930b3eb60eb308cf5d Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:07:05 +0300 Subject: [PATCH 14/15] Consistency in naming --- .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 2110b69..76deddc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -121,7 +121,7 @@ jobs: suffix="ci-${ref_clean}-${{ github.run_id }}" echo "suffix=${suffix}" >> $GITHUB_OUTPUT - - name: Create packages + - name: Run pack run: > dotnet pack --no-restore From 9ee386c843925d8c72f7403da4467b2f39f5e165 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:22:20 +0300 Subject: [PATCH 15/15] Move `ContinuousIntegrationBuild` to workflow file for consistency --- .github/workflows/main.yml | 12 ++++++++++-- Directory.Build.props | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 76deddc..5445d96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,7 +77,10 @@ jobs: run: dotnet restore - name: Run build - run: dotnet build --no-restore --configuration Release + run: > + dotnet build + --no-restore + --configuration Release - name: Run tests run: > @@ -108,7 +111,11 @@ jobs: run: dotnet restore - name: Run build - run: dotnet build --no-restore --configuration Release + run: > + dotnet build + --no-restore + --configuration Release + -p:ContinuousIntegrationBuild=true # When triggered by `push` or `pull_request` events, generate a prerelease version # for the package, so as to clearly indicate that it's not a stable version release. @@ -127,6 +134,7 @@ jobs: --no-restore --no-build --configuration Release + -p:ContinuousIntegrationBuild=true ${{ steps.prerelease-version.outputs.suffix && format('--version-suffix {0}', steps.prerelease-version.outputs.suffix) || '' }} - name: Upload artifacts diff --git a/Directory.Build.props b/Directory.Build.props index 2e64950..9bf8342 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,9 +4,8 @@ net8.0 false - true - + latest enable