-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add GitHub Actions workflow for automated releases #1
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
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,105 @@ | ||
| name: build-release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| # nuget | ||
| nuget-push: | ||
| description: "nuget-push: true = upload nuget package. false = not upload" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
|
|
||
| jobs: | ||
| test-dotnet: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| # test | ||
| - run: dotnet test -c Release | ||
|
|
||
| create-release: | ||
| needs: [test-dotnet] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| outputs: | ||
| new_release_published: ${{ steps.semantic.outputs.new_release_published }} | ||
| new_release_version: ${{ steps.semantic.outputs.new_release_version }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Semantic Release | ||
| uses: cycjimmy/semantic-release-action@v4 | ||
| id: semantic | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| create-nuget-package: | ||
|
||
| needs: [create-release] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| if: needs.create-release.outputs.new_release_published == 'true' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| # build and pack | ||
| - run: dotnet build -c Release -p:Version=${{ needs.create-release.outputs.new_release_version }} | ||
| - run: dotnet pack -c Release --no-build -p:Version=${{ needs.create-release.outputs.new_release_version }} -o ./publish | ||
| # Store artifacts. | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: nuget | ||
| path: ./publish/ | ||
| retention-days: 1 | ||
|
|
||
| push-nuget-package: | ||
|
||
| needs: [create-nuget-package] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| if: needs.create-release.outputs.new_release_published == 'true' | ||
| env: | ||
| NUGET_PATH: | | ||
| ./*.nupkg | ||
| ./*.snupkg | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
|
|
||
| # Download(All) Artifacts to current directory | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: nuget | ||
| - name: Show download aritifacts | ||
| run: ls -lR | ||
| - name: Validate package exists in artifact - NuGet | ||
| run: | | ||
| while read -r nuget_path; do | ||
| if [[ "${nuget_path}" == "" ]]; then continue; fi | ||
| # shellcheck disable=SC2086 | ||
| if ! ls -l ${nuget_path}; then | ||
| echo "Specified nuget package not found. path: $nuget_path" | ||
| if [[ "${nuget_path}" == *.nupkg ]]; then | ||
| echo ".nupkg must be included in the artifact." | ||
| exit 1 | ||
| fi | ||
| fi | ||
| done <<< "${NUGET_PATH}" | ||
|
|
||
| # Upload to NuGet | ||
| - name: Upload to NuGet | ||
| if: ${{ inputs.nuget-push }} | ||
| run: | | ||
| while read -r nuget_path; do | ||
| if [[ "$nuget_path" == "" ]]; then continue; fi | ||
| # shellcheck disable=SC2086 | ||
| if ! ls -l ${nuget_path} >/dev/null 2>&1;then | ||
| echo "skipping nuget push, $nuget_path not found." | ||
| continue | ||
| fi | ||
|
|
||
| dotnet nuget push "${nuget_path}" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}" | ||
| done <<< "${NUGET_PATH}" | ||
| env: | ||
| NUGET_KEY: ${{ secrets.PS_NUGET_KEY }} | ||
|
||
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,12 @@ | ||
| { | ||
| "plugins": [ | ||
| "@semantic-release/commit-analyzer", | ||
| "@semantic-release/release-notes-generator", | ||
| [ | ||
| "@semantic-release/github" | ||
| ] | ||
| ], | ||
| "branches": [ | ||
| "main" | ||
| ] | ||
| } |
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
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
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.