-
Notifications
You must be signed in to change notification settings - Fork 1
ci: add monthly release please automation #30
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,97 @@ on: | |
| push: | ||
| branches: | ||
| - master | ||
| schedule: | ||
| - cron: "0 3 1 * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update-dependencies: | ||
| if: ${{ github.event_name != 'push' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check whether 30 days have passed since the latest tag | ||
| id: cadence | ||
| shell: bash | ||
| run: | | ||
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||
| echo "should_run=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| latest_tag="$(git tag --sort=-creatordate | head -n 1)" | ||
|
|
||
| if [[ -z "$latest_tag" ]]; then | ||
| echo "should_run=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| now_epoch="$(date -u +%s)" | ||
| last_tag_epoch="$(git log -1 --format=%ct "$latest_tag")" | ||
| thirty_days=$((30 * 24 * 60 * 60)) | ||
|
|
||
| if (( now_epoch - last_tag_epoch >= thirty_days )); then | ||
| echo "should_run=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "should_run=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Setup .NET | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: | | ||
| 8.0.x | ||
| 9.0.x | ||
| 10.0.x | ||
|
|
||
| - name: Update NuGet dependencies | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| run: dotnet package update --project ./EasyScrutor.sln | ||
|
|
||
| - name: Restore dependencies | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| run: dotnet restore ./EasyScrutor.sln | ||
|
|
||
| - name: Verify code formatting | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| run: dotnet format ./EasyScrutor.sln --verbosity diagnostic | ||
|
|
||
| - name: Build | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| run: dotnet build ./EasyScrutor.sln --configuration Release --no-restore | ||
|
|
||
| - name: Run tests | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| run: dotnet test ./EasyScrutor.sln --configuration Release --no-build --verbosity normal | ||
|
|
||
| - name: Create pull request | ||
| if: ${{ steps.cadence.outputs.should_run == 'true' }} | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| branch: automation/monthly-dependency-updates | ||
| delete-branch: true | ||
| commit-message: "fix(deps): update dependencies" | ||
| title: "fix(deps): update dependencies" | ||
|
Comment on lines
+80
to
+87
|
||
| body: | | ||
| ## Summary | ||
| - update NuGet dependencies used by the solution | ||
| - verify formatting, build, and tests before opening the PR | ||
|
|
||
| ## Notes | ||
| - merging this PR will allow the existing release workflow to publish the next package version | ||
|
|
||
| release-please: | ||
| if: ${{ github.event_name == 'push' }} | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| release_created: ${{ steps.release.outputs.release_created }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
dotnet package updatecommand does not accept a--projectflag when targeting a.slnfile. For a solution file, the correct invocation is eitherdotnet package update ./EasyScrutor.sln(passing the.slnas a positional argument) or iterating over individual project files. The--projectflag is used withdotnetcommands that target a project, not a solution. This step will fail at runtime with an unrecognized option error.