Skip to content

This GitHub Action helps publish your PowerShell module to the PowerShell Gallery automatically.

Notifications You must be signed in to change notification settings

lazywolf4/publish-powershell-module

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Publish PowerShell Module

This GitHub Action enables you to publish a PowerShell module to the PowerShell Gallery or another Nuget-Based Repository.
Forked from: https://github.com/pcgeek86/publish-powershell-module-action

Usage

  1. Add a GitHub Actions Workflow configuration to your GitHub project, under .github/workflows/main.yml
  2. Configure a secret on your GitHub repository, containing your PowerShell Gallery NuGet API key
  3. Add the following step to your GitHub Actions job

For example, if you named your secret PS_GALLERY_KEY:

      - name: Publish Module to PowerShell Gallery
        uses: pcgeek86/publish-powershell-module-action@v20
        id: publish-module
        with:
          NuGetApiKey: ${{ secrets.PS_GALLERY_KEY }}
          moduleName: 'MyModule'
          modulePath: .\Modules\MyModule

Features

Custom Repository

You can use a custom Nuget repository with this parameters.

          NuGetApiKey: ${{ secrets.PRIVATEREPO_KEY }} 
          NugetRepository: Privaterepo
          NugetRepositorySourceUrl: ${{ vars.NUGET_REPOSITORY_SOURCE_URL }}
          NugetRepositoryPublishUrl: ${{ vars.NUGET_REPOSITORY_PUBLISH_URL }}

Autoversioning

You can automatically update the module version on change. This feature is inspired from powershellexplained.com

To use this feature enable it: AutoVersion: true

You should also use "autocommit" for adding the changed version to your git repostiory. (It stores a fingerprint, and the current version).

I recommend your this step for it:

      - name: Commit new version back
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: 'CICD: Updated PSVersion'
          commit_user_name: CICD

Automatically detect changed module (multiple modules in one git repository)

This feature requires the action tj-actions/changed-files configured like that:

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v44
        with:
          files: Modules/**
          json: true
          escape_json: false

Now you can passtrough the changed files:

          ChangedFiles: "${{ steps.changed-files.outputs.all_changed_and_modified_files }}"
          ChangedFilesIgnoredExtensions: "md,org"

Assumptions

  • You're writing a PowerShell script module (not a compiled module)
  • Your module is contained within a subfolder of your GitHub repository

About

This GitHub Action helps publish your PowerShell module to the PowerShell Gallery automatically.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 95.6%
  • Dockerfile 4.4%