Skip to content

Conversation

@jpshack-at-palomar
Copy link

@jpshack-at-palomar jpshack-at-palomar commented Mar 13, 2025

Support npm and GitHub Packages Publishing

This PR adds support for npm as an alternative to yarn in our GitHub workflows and adds the ability to publish to GitHub Packages.

Changes

1. Support npm for oclif readme generation

  • Added package-manager input parameter to create-github-release.yml workflow
  • Modified generateOclifReadme action to support both npm and yarn
  • Default remains as yarn for backward compatibility
  • No changes required for existing workflow calls

2. Add GitHub Packages publishing support

  • Added new input parameters to npmPublish.yml:
    • publishToGithubPackages: Boolean to toggle between npm and GitHub Packages
    • scope: Required when publishing to GitHub Packages (e.g., @organization)
  • Added conditional permissions for GitHub Packages publishing (only requests write access when needed)
  • Updated package existence check to work with both registries
  • Added input validation for GitHub Packages requirements
  • Uses SVC_CLI_BOT_GITHUB_TOKEN for GitHub Packages authentication

Usage Examples

Publishing to npm (existing behavior)

- uses: salesforcecli/github-workflows/.github/workflows/npmPublish.yml@main
  with:
    githubTag: v1.0.0
  secrets:
    NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Publishing to GitHub Packages

- uses: salesforcecli/github-workflows/.github/workflows/npmPublish.yml@main
  with:
    githubTag: v1.0.0
    publishToGithubPackages: true
    scope: '@your-org'
  secrets:
    SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Using npm for readme generation

- uses: salesforcecli/github-workflows/.github/workflows/create-github-release.yml@main
  with:
    generate-readme: true
    package-manager: npm

Testing

  • Tested publishing to npm (existing behavior)
  • Tested publishing to GitHub Packages
  • Tested readme generation with npm
  • Tested readme generation with yarn (existing behavior)
  • Verified backward compatibility (no changes needed for existing workflows)

Notes

  • The default package manager remains yarn for backward compatibility
  • GitHub Packages publishing requires a scope to be specified
  • The workflow will validate required inputs when publishing to GitHub Packages
  • Backward Compatible: No changes are required to existing workflows. The workflow handles permissions internally based on the publishToGithubPackages parameter.

@jpshack-at-palomar
Copy link
Author

Testing in progress...

@jpshack-at-palomar
Copy link
Author

What a mess. GitHub doesn't support dynamic values for uses so in order to test I have to hardcode values that are totally unsuitable for a merge. Blah.

@jpshack-at-palomar
Copy link
Author

The fork's main branch is much cleaner and has many new features but still would take some work to bring anything back. Closing for now. Happy to help with it if there is anything anyone wants to see come back to salesforcecli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant