natescherer / publish-powershell-action

A GitHub Action to publish a PowerShell module or script to GitHub Packages, a NuGet repository, or the PowerShell Gallery.
MIT License
11 stars 4 forks source link

My module has dependencies. Action fails... #10

Closed tig closed 10 months ago

tig commented 1 year ago
image

F7History.psd1 includes:

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @('Microsoft.PowerShell.ConsoleGuiTools', 'PSReadLine')

When I publish locally with

publish-Module -Path .\F7History\ -NuGetApiKey <key>

It works fine. What am i doing wrong?

name: Publish to PowerShell Gallery

on:
  push:
    branches:
      - main

jobs:
  publish:
    runs-on: ubuntu-latest
    # steps:
    #   - name: Check out code
    #     uses: actions/checkout@v2

    steps:
      - name: Check out code
        uses: actions/checkout@v2
      - name: Publish PowerShell
        uses: natescherer/publish-powershell-action@v1.0.3
        with:
          token: ${{ secrets.F7HISTORY_GALLERY_KEY }}
          target: gallery
          path: src
moonwitch commented 1 year ago

I've removed all those from my PSD1 file just to work around this issue.

natescherer commented 1 year ago

This seems like it might be a bug in PSResourceGet. Looking into it now. @moonwitch, would you mind sharing your .psd1 as well?

natescherer commented 1 year ago

@tig Would you mind sharing your full .psd1 as well?

tig commented 1 year ago

@tig Would you mind sharing your full .psd1 as well?

https://github.com/gui-cs/F7History.

natescherer commented 1 year ago

Think I figured it out. Looks like this issue: https://github.com/PowerShell/PSResourceGet/issues/903

Basically, Publish-PSResource uses Test-ModuleManifest, and Test-ModuleManifest fails if the modules in RequiredModules aren't installed, which they most likely would not be on an Actions Runner.

Should be an easy enough fix, hope to have something in the next few days.

moonwitch commented 1 year ago
#
# Module manifest for module 'Manage-Users'
#
# Generated by: Crabbé Kelly
#
# Generated on: 11/01/2022
#

@{
  # Script module or binary module file associated with this manifest.
  RootModule        = 'Manage-Users'

  # Version number of this module.
  ModuleVersion     = '1.2'

  # ID used to uniquely identify this module
  GUID              = '754a45ec-24de-4937-8ec4-55ebcbb2a1af'

  # Author of this module
  Author            = 'Crabbé Kelly'

  # Company or vendor of this module
  CompanyName       = 'Lineas NV'

  # Description of the functionality provided by this module
  Description       = 'Various functions to manually remove or add users following our user movement flow.'

  # Minimum version of the Windows PowerShell engine required by this module
  PowerShellVersion = '5.0'

  # Modules that must be imported into the global environment prior to importing this module
  RequiredModules   = @('ActiveDirectory', 'Microsoft.Graph')

  # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
  PrivateData       = @{

    PSData = @{
      Tags                       = @('Users', 'JML', 'Leaver', 'user-out')
      #ExternalModuleDependencies = @('ActiveDirectory')

      # A URL to the main website for this project.
      # ProjectUri = ''

      # A URL to an icon representing this module.
      # IconUri = ''

      # ReleaseNotes of this module
      # ReleaseNotes = ''

    } # End of PSData hashtable

  } # End of PrivateData hashtable

  # HelpInfo URI of this module
  # HelpInfoURI = ''

  # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
  # DefaultCommandPrefix = ''

}
natescherer commented 1 year ago

Okay, @tig and @moonwitch this should have been fixed by #17.

I added tests for packages with dependencies, which failed at first, and I then updated to bypass Test-ModuleManifest for modules with dependencies. Those test packages now deploy.

Give it a shot with the new v1.1.1 and let me know!

moonwitch commented 1 year ago

I did, however, I now get a different error. Will poke around some more though.

image
natescherer commented 1 year ago

That looks like an auth issue to GitHub packages. Assuming you are authing using GITHUB_TOKEN, if that's an existing package, make sure you've granted your repo access via the Actions settings in the package's settings.

natescherer commented 10 months ago

I'm going to assume this issue is resolved now based upon my own testing and close this issue, but if you are still seeing problems, please let me know!