Skip to content
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

add support for NUGET publishing actions #169

Closed
wants to merge 1 commit into from
Closed

Conversation

tomlm
Copy link
Collaborator

@tomlm tomlm commented Dec 5, 2024

for #167
PublishNuget

  • builds release and publishes nuget and symbol nuget for the current checked in version

PublishIncrementNuget

  • Bumps incremental build number (11.2.X)
  • builds release and publishes nuget and symbol nuget for the
  • Checks in updated build number

NOTE: This needs a NUGET_KEY secret added

 **PublishNuget**
- builds release and publishes nuget and symbol nuget for the current checked in version

 **PublishIncrementNuget**
- Bumps incremental build number (11.2.X)
- builds release and publishes nuget and symbol nuget for the
- Checks in updated build number

NOTE: This needs a NUGET_KEY secret added
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

📝 Walkthrough

Walkthrough

The changes introduced in this pull request consist of two new GitHub Actions workflow files: PublishIncrementalNuget.yml and PublishNuget.yml.

The PublishIncrementalNuget.yml file automates the process of publishing incremental NuGet releases. It is triggered manually and includes a job that runs on the latest Ubuntu environment. The workflow encompasses several steps, including checking out the repository, setting up the .NET environment, updating the project version, restoring dependencies, building the solution, packing the NuGet packages, publishing them to a NuGet repository, and committing the version changes back to the repository.

Similarly, the PublishNuget.yml file automates the publishing of a NuGet package. This workflow is also manually triggered and includes a job that runs on the latest Ubuntu version. The steps include checking out the repository, setting up the .NET SDK, restoring dependencies, building the solution, packing the NuGet package, and publishing it along with its symbols to a NuGet repository.

Both workflows are designed to streamline the build and publish processes for NuGet packages in .NET projects.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (3)
.github/workflows/PublishNuget.yml (2)

1-4: Consider adding environment protection rules

While manual triggering provides control, consider adding environment protection rules to restrict who can trigger this workflow, especially since it involves publishing packages.

Add environment configuration:

on:
  workflow_dispatch:

+environment:
+  name: production
+  rules:
+    - if: github.ref == 'refs/heads/main'

1-35: Remove trailing spaces

Multiple lines contain trailing spaces. While not critical, it's good practice to remove them for consistency.

You can use an editor command or sed to remove trailing spaces:

sed -i 's/[[:space:]]*$//' .github/workflows/PublishNuget.yml
🧰 Tools
🪛 actionlint (1.7.4)

14-14: the runner of "actions/setup-dotnet@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 10-10: trailing spaces

(trailing-spaces)


[error] 12-12: trailing spaces

(trailing-spaces)


[error] 17-17: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 23-23: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)


[error] 32-32: trailing spaces

(trailing-spaces)


[error] 35-35: trailing spaces

(trailing-spaces)

.github/workflows/PublishIncrementalNuget.yml (1)

6-8: Add workflow-level controls

Consider adding the following improvements:

  1. Concurrency control to prevent multiple version bumps
  2. Artifact retention for troubleshooting

Add these configurations at the workflow level:

jobs:
+ concurrency:
+   group: ${{ github.workflow }}-${{ github.ref }}
+   cancel-in-progress: true
  build:
    runs-on: ubuntu-latest
+    outputs:
+      nuget-package: ${{ steps.pack.outputs.package-path }}

And after the pack step:

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: nuget-packages
          path: packages/
          retention-days: 5
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b0a8224 and d6309c1.

📒 Files selected for processing (2)
  • .github/workflows/PublishIncrementalNuget.yml (1 hunks)
  • .github/workflows/PublishNuget.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/PublishIncrementalNuget.yml

14-14: the runner of "actions/setup-dotnet@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/PublishNuget.yml

14-14: the runner of "actions/setup-dotnet@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)
.github/workflows/PublishIncrementalNuget.yml

[error] 10-10: trailing spaces

(trailing-spaces)


[error] 12-12: trailing spaces

(trailing-spaces)


[error] 17-17: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


[error] 30-30: trailing spaces

(trailing-spaces)


[error] 31-31: trailing spaces

(trailing-spaces)


[error] 32-32: trailing spaces

(trailing-spaces)


[error] 40-40: trailing spaces

(trailing-spaces)


[error] 43-43: trailing spaces

(trailing-spaces)

.github/workflows/PublishNuget.yml

[error] 10-10: trailing spaces

(trailing-spaces)


[error] 12-12: trailing spaces

(trailing-spaces)


[error] 17-17: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 23-23: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)


[error] 32-32: trailing spaces

(trailing-spaces)


[error] 35-35: trailing spaces

(trailing-spaces)

🔇 Additional comments (1)
.github/workflows/PublishIncrementalNuget.yml (1)

22-24: Verify project file targeting

The current glob pattern **/Consolonia.csproj might match multiple project files if there are similarly named files in different directories. Consider using a more specific path.

Comment on lines +13 to +16
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update setup-dotnet action version and consider pinning .NET version

The current setup has two potential improvements:

  1. The setup-dotnet action version is outdated
  2. The .NET version could be more specific to ensure reproducible builds

Apply this diff:

- uses: actions/setup-dotnet@v3
+ uses: actions/setup-dotnet@v4
  with:
-   dotnet-version: 8.0.x
+   dotnet-version: 8.0.100
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
🧰 Tools
🪛 actionlint (1.7.4)

14-14: the runner of "actions/setup-dotnet@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/PublishNuget.yml Show resolved Hide resolved
.github/workflows/PublishNuget.yml Show resolved Hide resolved
.github/workflows/PublishIncrementalNuget.yml Show resolved Hide resolved
.github/workflows/PublishIncrementalNuget.yml Show resolved Hide resolved
.github/workflows/PublishIncrementalNuget.yml Show resolved Hide resolved
Comment on lines +44 to +49
- name: Commit new version changes
run: |
git config --global user.name "Github Action"
git config --global user.email "[email protected]"
git commit -a -m "Bumped version for published nuget artifacts"
git push
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve git configuration and error handling

Several improvements needed for the git operations:

  1. Use GitHub's default action bot email instead of hardcoding a user's email
  2. Add error handling for git operations
  3. Verify changes exist before committing
      - name: Commit new version changes
        run: |
          git config --global user.name "Github Action"
-         git config --global user.email "[email protected]"
+         git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
+         if [[ -n "$(git status --porcelain)" ]]; then
            git commit -a -m "Bumped version for published nuget artifacts"
            git push
+         else
+           echo "No changes to commit"
+         fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Commit new version changes
run: |
git config --global user.name "Github Action"
git config --global user.email "[email protected]"
git commit -a -m "Bumped version for published nuget artifacts"
git push
- name: Commit new version changes
run: |
git config --global user.name "Github Action"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
if [[ -n "$(git status --porcelain)" ]]; then
git commit -a -m "Bumped version for published nuget artifacts"
git push
else
echo "No changes to commit"
fi

@tomlm tomlm closed this Dec 5, 2024
@tomlm tomlm self-assigned this Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant