Ashwin Nambiar
Ashwin Nambiar

Reputation: 86

How to install a nuget package from github actions

I've been trying to use GitHub actions to automate package updation from one repo to the next. I currently have a repo on which a new release will be made and i want to take that new package to the next repo (using as a dependency).

repo 1 -> release -> repo 2 -> install.

I have set up a trigger and wait workflow but the triggered workflow is supposed to install the package from repo 1's release.

It seems as though the workflow is executing but when i check package.config, i can still see that it's not updated to the latest release from repo 1.

name : Install Latest Core Package
on:
  workflow_dispatch:
  push:
    branches:
      - SOF-4565-AutomatePackageUpdate
env: 
  ACTIONS_ALLOW_UNSECURE_COMMANDS : true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:  
      - name: Setup .NET Core SDK
        uses: actions/[email protected]
      
      - name: Nuget Add Source
        run: nuget sources Add -Name github -Source PATH -UserName USER -Password ${{ secrets.NUGET_TOKEN }}
      
      - name: Core package update
        run: dotnet nuget add source PATH -n github -u ${{ github.actor }} -p ${{ secrets.NUGET_TOKEN }} --store-password-in-clear-text

I have tried with this .yml file. Is there something that I'm missing?

EDIT :

This is the only change I see in logs when I do the required action locally

enter image description here

On github, when i run "nuget install PACKAGE" It's adding the packages to the root but its not updating the config file. I'd like to update the package.config and add the package files to the bin folder.

Upvotes: 3

Views: 2812

Answers (1)

Chenna
Chenna

Reputation: 2623

In your yaml file I observe that you only added nuget source, later you need to bump the package and commit to git

- name: Bump Package
  run: |
     dotnet add package <package_name> --version ${{ needs.PublishPackages.outputs.buildVersion }}
     git commit -a -m "Bump to ${{ github.event.head_commit.message }}" -m "Version <githubusername_orgname>/<nuget_package_repo_name>@${{ needs.PublishPackages.outputs.sha7 }}"
     git push

I had similar requirement, incase if you want you read in detail

Upvotes: 0

Related Questions