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

Automatically updating NuGet packages #75

Open
VahidN opened this issue Aug 13, 2024 · 0 comments
Open

Automatically updating NuGet packages #75

VahidN opened this issue Aug 13, 2024 · 0 comments

Comments

@VahidN
Copy link

VahidN commented Aug 13, 2024

Github supports actions with cron jobs. If you add GeneratePackageOnBuild to the .csproj to build a .nupkg file automatically, it's easy to push it to the NuGet server this way:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    </PropertyGroup>
name: .NET Core Build

on:
  push:
    branches: [ "main" ]
  schedule:
    - cron: "30 23 * * *"

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

      - name: Setup .NET Core
        uses: actions/setup-dotnet@v3
        with:
            dotnet-version: 8.0.x

    - name: Build library
      run: dotnet build ./UAParser/UAParser.csproj --configuration Release

    - name: Push Package to NuGet.org
      run: dotnet nuget push **\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate

This is a sample .github\workflows\build.yml file's content with a cron job which executes every night and automatically builds the project, creates the nuget package and then sends it to the nuget server. The NUGET_API_KEY should be defined in the settings/secrets/actions section of this repository as a new Repository secret.

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

No branches or pull requests

1 participant