Repository navigation
Improve CI #259
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
Merged
Improve CI #259
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e518f0c
Delete .github/workflows/build-and-test.yml
304NotModified b4cf5b5
Delete .github/workflows/nuget.yml
304NotModified 3927e06
Create ci.yml
304NotModified 49fedfb
Update README.md
304NotModified 0a534fc
names and commit hash login
304NotModified 41e8ef4
remove quotes
304NotModified 3f7e0cb
Update README.md
304NotModified 045b918
no-restore
304NotModified 29387bc
Update Upload NuGet package
304NotModified 28962c0
docs
304NotModified 92c6398
simplify version suffix
304NotModified 80d9a21
fix artifact name
304NotModified ca91165
-ci
304NotModified dcf2533
Update ci.yml
304NotModified 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 was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| workflow_dispatch: | ||
| inputs: | ||
| force_nuget_publish: | ||
| description: Force NuGet publish # for non-master. The package version gets a suffix. See Create NuGet Package step | ||
| type: boolean | ||
| default: false | ||
|
|
||
| env: | ||
| SOLUTION: src/NLog.MailKit.sln | ||
| DOTNET_VERSION: 8.0.x | ||
|
|
||
| jobs: | ||
| build: | ||
| name: ${{ matrix.name }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: windows-latest | ||
| name: Build, test & NuGet package (Windows) | ||
| create_nuget_package: true | ||
| - os: ubuntu-latest | ||
| name: Build & test (Ubuntu) | ||
| create_nuget_package: false | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v6 | ||
| with: | ||
| dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
|
||
| - name: Restore | ||
| run: dotnet restore ${{ env.SOLUTION }} | ||
|
|
||
| - name: Build | ||
| run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore | ||
|
|
||
| - name: Test | ||
| run: dotnet test ${{ env.SOLUTION }} --configuration Release --no-restore --no-build --logger "console;verbosity=normal" | ||
|
|
||
| - name: Determine version suffix | ||
| if: matrix.create_nuget_package | ||
| id: version | ||
| shell: pwsh | ||
| env: | ||
| REF: ${{ github.ref }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| RUN_NUMBER: ${{ github.run_number }} | ||
| run: | | ||
| if ($env:REF -eq "refs/heads/master") { | ||
| echo "suffix=" >> $env:GITHUB_OUTPUT | ||
| } elseif ($env:PR_NUMBER) { | ||
| echo "suffix=pr.$($env:PR_NUMBER).ci.$($env:RUN_NUMBER)" >> $env:GITHUB_OUTPUT | ||
| } else { | ||
| echo "suffix=ci.$($env:RUN_NUMBER)" >> $env:GITHUB_OUTPUT | ||
| } | ||
|
|
||
| - name: Create NuGet package | ||
| if: matrix.create_nuget_package | ||
| shell: pwsh | ||
| env: | ||
| VERSION_SUFFIX: ${{ steps.version.outputs.suffix }} | ||
| run: | | ||
| if ($env:VERSION_SUFFIX) { | ||
| dotnet pack $env:SOLUTION --no-build --configuration Release --output artifacts --version-suffix "$env:VERSION_SUFFIX" | ||
| } else { | ||
| dotnet pack $env:SOLUTION --no-build --configuration Release --output artifacts | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Guess you have to replace
|
||
| } | ||
|
|
||
| - name: Upload NuGet package | ||
| if: matrix.create_nuget_package | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: NuGetPackages | ||
| path: | | ||
| artifacts/*.nupkg | ||
| artifacts/*.snupkg | ||
| if-no-files-found: error | ||
|
|
||
| publish: | ||
| name: Publish NuGet package | ||
| needs: build | ||
| if: >- | ||
| (github.event_name == 'push' && github.ref == 'refs/heads/master') || | ||
|
snakefoot marked this conversation as resolved.
|
||
| (github.event_name == 'workflow_dispatch' && inputs.force_nuget_publish) | ||
| runs-on: windows-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Download NuGet package | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: NuGetPackages | ||
| path: artifacts | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v6 | ||
| with: | ||
| dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
|
||
| - name: NuGet login | ||
| uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2 | ||
| id: login | ||
| with: | ||
| user: ${{ secrets.NUGET_USER }} | ||
|
|
||
| - name: Push to NuGet.org | ||
| shell: pwsh | ||
| env: | ||
| NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} | ||
| run: dotnet nuget push artifacts\*.nupkg --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
This file was deleted.
Oops, something went wrong.
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.