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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/PublishIncrementalNuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Incremental Nuget Release

on:
workflow_dispatch:
tomlm marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
tomlm marked this conversation as resolved.
Show resolved Hide resolved

- name: Bump build version
id: bump
uses: vers-one/[email protected]
with:
files: |
"**/Consolonia.csproj"
version: bump-build

- name: Restore dependencies
run: dotnet restore source/Consolonia.sln

- name: Build
run: dotnet build source/Consolonia.sln -c Release --no-restore

- name: dotnet pack
run: |
dotnet pack --no-build source/Consolonia.sln -c Release -o packages --include-symbols --property WarningLevel=0
tomlm marked this conversation as resolved.
Show resolved Hide resolved

- name: Publish NuGet and symbols
id: nuget-push
uses: edumserrano/nuget-push@v1
with:
api-key: '${{ secrets.NUGET_KEY }}'
working-directory: 'packages'
fail-if-exists: false

- 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
Comment on lines +44 to +49
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

35 changes: 35 additions & 0 deletions .github/workflows/PublishNuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Nuget Release

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
Comment on lines +13 to +16
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)


- name: Restore dependencies
run: dotnet restore source/Consolonia.sln

- name: Build
run: dotnet build source/Consolonia.sln -c Release --no-restore

- name: dotnet pack
run: |
dotnet pack --no-build source/Consolonia.sln -c Release -o packages --include-symbols --property WarningLevel=0
tomlm marked this conversation as resolved.
Show resolved Hide resolved

- name: Publish NuGet and symbols
id: nuget-push
uses: edumserrano/nuget-push@v1
with:
api-key: '${{ secrets.NUGET_KEY }}'
working-directory: 'packages'
fail-if-exists: false
tomlm marked this conversation as resolved.
Show resolved Hide resolved

Loading