-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update CI workflows and project files for improved package management and versioning #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d591885
Update CI workflows and project files for improved package management…
Shane32 ea36509
Update GitHub Actions to use v8 of the GitHub script action and adjus…
Shane32 bb4c730
Add missing shell declaration for version setting and validation steps
Shane32 e6a77e2
Update .github/workflows/wf-build-release.yml
Shane32 8ed4c93
Update .github/workflows/wf-build-release-ci.yml
Shane32 e1fbb09
Merge branch 'master' into ci
Shane32 5d5b524
Merge branch 'master' into ci
Shane32 d47e53f
Merge from master
Shane32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,195 +1,72 @@ | ||
| name: Build, test, pack, push (Release) | ||
| name: Build, pack, push (Release) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| releaseNotes: | ||
| description: 'Release Notes (use `n for new line)' | ||
| required: true | ||
| jobs: | ||
| build: | ||
| runs-on: windows-latest | ||
| env: | ||
| ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
| release: | ||
| types: | ||
| - published | ||
|
|
||
| jobs: | ||
| pack-push-ci: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v5 | ||
| name: Checkout Code | ||
|
|
||
| - name: Install additional .NET SDKs | ||
| uses: actions/setup-dotnet@v4 | ||
| - name: Check github.ref starts with 'refs/tags/' | ||
| if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
| shell: bash | ||
| run: | | ||
| echo Error! github.ref does not start with 'refs/tags' | ||
| echo github.ref: ${{ github.ref }} | ||
| exit 1 | ||
|
|
||
| - name: Set version number environment variable | ||
| env: | ||
| github_ref: ${{ github.ref }} | ||
| shell: bash | ||
| run: | | ||
| version="${github_ref:10}" | ||
| echo version=$version | ||
| echo "version=$version" >> $GITHUB_ENV | ||
|
Shane32 marked this conversation as resolved.
|
||
|
|
||
| - name: Install .NET SDK | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: | | ||
| 1.0.x | ||
| 2.0.x | ||
| 5.0.x | ||
| 6.0.x | ||
| 8.0.x | ||
| dotnet-version: 8.0.x | ||
| source-url: https://api.nuget.org/v3/index.json | ||
| env: | ||
| NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}} | ||
|
|
||
| - name: Restore NuGet Packages | ||
| run: dotnet restore | ||
|
|
||
| - name: Build library | ||
| run: dotnet build -c Release --no-restore | ||
| - name: Build NuGet packages | ||
| shell: bash | ||
| run: dotnet pack -c Release -p:Version=$version -o out | ||
|
Shane32 marked this conversation as resolved.
Shane32 marked this conversation as resolved.
|
||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: Compiled project | ||
| path: ${{ github.workspace }} | ||
|
|
||
| test: | ||
| needs: build | ||
| runs-on: windows-latest | ||
| steps: | ||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: Compiled project | ||
| path: ${{ github.workspace }} | ||
|
|
||
| - name: Install additional .NET SDKs | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: | | ||
| 1.0.x | ||
| 2.0.x | ||
| 5.0.x | ||
| 6.0.x | ||
| 8.0.x | ||
|
|
||
| - name: Run test .NET 3.5 | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f net35 --nologo --no-build # No coverage for NET3.5 because of bug in combination with Coverlet+Stronh naming | ||
|
|
||
| - name: Run test .NET 4.52 | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f net452 --nologo --no-build # No coverage for NET4.5 because of bug in combination with Coverlet+Strong naming | ||
|
|
||
| - name: Run test .NET Core 1.1 | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f netcoreapp1.1 --nologo # No coverage for .NETCORE 1.1 because Coverlet doesn't support it https://github.com/coverlet-coverage/coverlet/issues/466 | ||
|
|
||
| - name: Run test .NET Core 2.0 | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f netcoreapp2.0 --nologo /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | ||
|
|
||
| - name: Run test .NET 5.0 | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f net5.0 --nologo --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | ||
|
|
||
| - name: Run test .NET 5.0 Windows | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f net5.0-windows --nologo --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | ||
|
|
||
| - name: Run test .NET 6.0 | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f net6.0 --nologo --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | ||
|
|
||
| - name: Run test .NET 6.0 Windows | ||
| working-directory: QRCoderTests | ||
| run: dotnet test -c Release -f net6.0-windows --nologo --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | ||
|
|
||
| - name: Run API approval tests | ||
| working-directory: QRCoderApiTests | ||
| run: dotnet test -c Release --nologo --no-build | ||
|
|
||
| - name: Codecov update netcoreapp2.0 | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| disable_search: true | ||
| fail_ci_if_error: true | ||
| files: ./QRCoderTests/coverage.netcoreapp2.0.opencover.xml | ||
| flags: netcoreapp2.0 | ||
| name: Nuget packages | ||
| path: out/* | ||
|
|
||
| - name: Codecov update net5.0 | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| disable_search: true | ||
| fail_ci_if_error: true | ||
| files: ./QRCoderTests/coverage.net5.0.opencover.xml | ||
| flags: net5.0 | ||
| - name: Publish packages to Github packages | ||
| run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}} | ||
|
|
||
| - name: Codecov update net5.0-windows | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| disable_search: true | ||
| fail_ci_if_error: true | ||
| files: ./QRCoderTests/coverage.net5.0-windows.opencover.xml | ||
| flags: net5.0-windows | ||
|
|
||
| - name: Codecov update net6.0 | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| disable_search: true | ||
| fail_ci_if_error: true | ||
| files: ./QRCoderTests/coverage.net5.0.opencover.xml | ||
| flags: net6.0 | ||
|
|
||
| - name: Codecov update net6.0-windows | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| disable_search: true | ||
| fail_ci_if_error: true | ||
| files: ./QRCoderTests/coverage.net5.0-windows.opencover.xml | ||
| flags: net6.0-windows | ||
|
|
||
| pack-push-release: | ||
| needs: test | ||
| runs-on: windows-latest | ||
| env: | ||
| GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: Compiled project | ||
| path: ${{ github.workspace }} | ||
|
|
||
| - name: Install additional .NET SDKs | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: | | ||
| 1.0.x | ||
| 2.0.x | ||
| 5.0.x | ||
| 6.0.x | ||
| 8.0.x | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Get assembly version QRCoder | ||
| run: echo "ASSEM_VER=$([Reflection.Assembly]::Loadfile( $(-join($pwd,"\QRCoder\bin\Release\net40\QRCoder.dll"))).GetName().version.ToString())" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | ||
|
|
||
| - name: Clean assembly version QRCoder | ||
| run: echo "ASSEM_VER_SHT=$($env:ASSEM_VER.substring(0, $env:ASSEM_VER.lastIndexOf(".")))" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | ||
|
|
||
| - name: Get assembly version QRCoder.Xaml | ||
| run: echo "ASSEM_VER_XAML=$([Reflection.Assembly]::Loadfile( $(-join($pwd,"\QRCoder.Xaml\bin\Release\net40\QRCoder.Xaml.dll"))).GetName().version.ToString())" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | ||
|
|
||
| - name: Clean assembly version QRCoder.Xaml | ||
| run: echo "ASSEM_VER_SHT_XAML=$($env:ASSEM_VER_XAML.substring(0, $env:ASSEM_VER_XAML.lastIndexOf(".")))" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | ||
|
|
||
| - name: Build QRCoder NuGet package | ||
| run: dotnet pack QRCoder\QRCoder.csproj -c Release --no-build /p:PackageVersion="$env:ASSEM_VER_SHT" /p:PackageReleaseNotes="${{ github.event.inputs.releaseNotes }}" | ||
|
|
||
| - name: Build QRCoder.Xaml NuGet package | ||
| run: dotnet pack QRCoder.Xaml\QRCoder.Xaml.csproj -c Release --no-build /p:PackageVersion="$env:ASSEM_VER_SHT_XAML" /p:PackageReleaseNotes="${{ github.event.inputs.releaseNotes }}" | ||
|
|
||
| - name: Publish QRCoder and QRCoder.Xaml to Github packages | ||
| run: dotnet nuget push "**/*.nupkg" --no-symbols --skip-duplicate --api-key $env:GH_PKG_SEC --source https://nuget.pkg.github.com/codebude/index.json | ||
|
|
||
|
|
||
| clean: | ||
| needs: [build, test, pack-push-release] | ||
| if: always() | ||
| runs-on: windows-latest | ||
| steps: | ||
| - name: Delete artifacts | ||
| uses: GeekyEggo/delete-artifact@v5 | ||
| - name: Upload Nuget packages as release artifacts | ||
| uses: actions/github-script@v8 | ||
| with: | ||
|
Shane32 marked this conversation as resolved.
|
||
| name: Compiled project | ||
| github-token: ${{secrets.GITHUB_TOKEN}} | ||
| script: | | ||
| console.log('environment', process.versions); | ||
| const fs = require('fs').promises; | ||
| const { repo: { owner, repo }, sha } = context; | ||
|
|
||
| for (let file of await fs.readdir('out')) { | ||
| console.log('uploading', file); | ||
|
|
||
| await github.rest.repos.uploadReleaseAsset({ | ||
| owner, | ||
| repo, | ||
| release_id: ${{ github.event.release.id }}, | ||
| name: file, | ||
| data: await fs.readFile(`out/${file}`) | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.