forked from QuestPDF/QuestPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Add github actions #16
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d0945bd
chore: add workflow files for pull-requests, code-scan, release and p…
1fabi0 6843e06
chore: add slnx files to restore and build path
1fabi0 dc83cbe
chore: address review comments
1fabi0 12d91d6
chore: use nuget login action
1fabi0 690efde
chore: harden workflows
1fabi0 5012a7b
chore: fix check for forked prs
1fabi0 a82405b
chore: give release higher permissions
1fabi0 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Code Scan | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| push: | ||
| branches: | ||
| - main | ||
| schedule: | ||
| - cron: '0 0 * * 1' # Every Monday at 00:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| jobs: | ||
| scan: | ||
| name: Trivy Code Scan | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Run Trivy vulnerability scanner | ||
| uses: aquasecurity/trivy-action@v0.35.0 | ||
| with: | ||
| scan-type: 'fs' | ||
| scan-ref: '.' | ||
| format: 'sarif' | ||
| output: 'trivy-results.sarif' | ||
|
|
||
| - name: Upload Trivy results to GitHub Security | ||
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} | ||
| uses: github/codeql-action/upload-sarif@v4 | ||
| with: | ||
| sarif_file: 'trivy-results.sarif' | ||
| category: 'Trivy' | ||
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,82 @@ | ||
| name: Publish | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| required: true | ||
| type: string | ||
| description: 'Version to publish (e.g., 1.0.0)' | ||
| notes: | ||
| required: true | ||
| type: string | ||
| description: 'Release notes for the NuGet package' | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish to NuGet | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| global-json-file: src/global.json | ||
|
|
||
| - name: Build | ||
| run: | | ||
| dotnet build \ | ||
| --configuration Release \ | ||
| src/ShinyPDF/ShinyPDF.csproj \ | ||
| /p:Version=${{ inputs.version }} \ | ||
| /p:AssemblyVersion=${{ inputs.version }} \ | ||
| /p:FileVersion=${{ inputs.version }} \ | ||
| /p:InformationalVersion=${{ inputs.version }} | ||
|
|
||
|
1fabi0 marked this conversation as resolved.
|
||
| - name: Write package release notes file | ||
| env: | ||
| PACKAGE_RELEASE_NOTES_RAW: ${{ inputs.notes }} | ||
| run: | | ||
| printf '%s' "$PACKAGE_RELEASE_NOTES_RAW" > "$RUNNER_TEMP/release-notes.txt" | ||
|
|
||
| - name: Pack NuGet package | ||
| run: | | ||
| dotnet pack \ | ||
| --configuration Release \ | ||
| --no-build \ | ||
| --no-restore \ | ||
| --output . \ | ||
| src/ShinyPDF/ShinyPDF.csproj \ | ||
| /p:Version=${{ inputs.version }} \ | ||
| /p:PackageVersion=${{ inputs.version }} \ | ||
| /p:AssemblyVersion=${{ inputs.version }} \ | ||
| /p:FileVersion=${{ inputs.version }} \ | ||
| /p:InformationalVersion=${{ inputs.version }} \ | ||
| /p:PackageReleaseNotesFile="$RUNNER_TEMP/release-notes.txt" | ||
|
|
||
| - name: NuGet login | ||
| uses: NuGet/login@v1 | ||
| id: login | ||
| with: | ||
| user: ${{ secrets.NUGET_USER }} | ||
|
|
||
| - name: Publish to NuGet | ||
| env: | ||
| NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} | ||
| run: | | ||
| dotnet nuget push "*.nupkg" \ | ||
| --api-key "$NUGET_API_KEY" \ | ||
| --source https://api.nuget.org/v3/index.json \ | ||
| --skip-duplicate | ||
|
|
||
| dotnet nuget push "*.snupkg" \ | ||
| --api-key "$NUGET_API_KEY" \ | ||
| --source https://api.nuget.org/v3/index.json \ | ||
| --skip-duplicate | ||
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,50 @@ | ||
| name: Pull Request | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
| checks: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build and Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| global-json-file: src/global.json | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore src/ShinyPDF.slnx | ||
|
|
||
| - name: Build | ||
| run: dotnet build src/ShinyPDF.slnx --configuration Release --no-restore | ||
|
1fabi0 marked this conversation as resolved.
|
||
|
|
||
| - name: Run unit tests | ||
| run: | | ||
| dotnet test \ | ||
| src/ShinyPDF.UnitTests/ShinyPDF.UnitTests.csproj \ | ||
| --configuration Release \ | ||
| --no-build \ | ||
| --results-directory src/ShinyPDF.UnitTests/TestResults \ | ||
| --verbosity normal \ | ||
| --logger "trx;LogFileName=test-results.trx" | ||
|
|
||
| - name: Parse and report test results | ||
| if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository }} | ||
| uses: dorny/test-reporter@v3 | ||
| with: | ||
| name: Unit Test Results | ||
| path: 'src/ShinyPDF.UnitTests/TestResults/test-results.trx' | ||
| reporter: 'dotnet-trx' | ||
|
1fabi0 marked this conversation as resolved.
|
||
| fail-on-error: false | ||
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,51 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
1fabi0 marked this conversation as resolved.
|
||
| id-token: write | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Create GitHub release | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| version: ${{ steps.changelog.outputs.version }} | ||
| clean_changelog: ${{ steps.changelog.outputs.clean_changelog }} | ||
| skipped: ${{ steps.changelog.outputs.skipped }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Generate version from Conventional Commits | ||
| id: changelog | ||
| uses: TriPSs/conventional-changelog-action@v6 | ||
| with: | ||
| fallback-version: 1.0.0 | ||
|
|
||
|
|
||
| - name: Create GitHub release | ||
| if: ${{ steps.changelog.outputs.skipped == 'false' }} | ||
| uses: softprops/action-gh-release@v3 | ||
| with: | ||
| tag_name: ${{ steps.changelog.outputs.tag }} | ||
| name: ${{ steps.changelog.outputs.version }} | ||
| body: ${{ steps.changelog.outputs.clean_changelog }} | ||
|
|
||
| publish: | ||
| name: Publish to NuGet | ||
| needs: release | ||
| if: ${{ needs.release.result == 'success' && needs.release.outputs.skipped == 'false' }} | ||
| uses: ./.github/workflows/publish.yaml | ||
| secrets: inherit | ||
| with: | ||
| version: ${{ needs.release.outputs.version }} | ||
| notes: ${{ needs.release.outputs.clean_changelog }} | ||
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
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.