Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

📦 Salesforce CI Packager (2GP)

A powerful GitHub Action that simplifies and automates the creation of Second-Generation Packages (2GP) for Salesforce. Say goodbye to manual package creation and hello to streamlined CI/CD workflows!

GitHub stars License

✨ Why Use This Action?

Creating and managing Salesforce 2GP packages can be time-consuming and error-prone. This action transforms your packaging experience:

  • 🚀 Accelerate Delivery - Automate package creation in your CI/CD pipeline
  • 🔄 Ensure Consistency - Standardize package versioning across your organization
  • ⏱️ Save Time - Eliminate manual steps in your release process
  • 📊 Gain Visibility - Track package creation status with detailed reporting
  • 🔌 Plug and Play - Integrate seamlessly with your existing GitHub workflows
  • 🛡️ Reduce Errors - Eliminate common mistakes in the packaging process

🛠️ Key Features

  • 🔐 Authenticate with a Salesforce Dev Hub org
  • 📦 Create a new package version with customizable options
  • 🔄 Poll for package creation status
  • ✏️ Update package aliases in the sfdx-project.json file
  • ⚙️ Configurable timeout and polling intervals

📋 Inputs

Name Description Required Default
auth-url The URL of the Dev Hub org. This is used to create an auth file for the Dev Hub org. Yes
package-name Name of the package to create a version of. Yes
package-type The type of package to create. It can be either "Managed" or "Unlocked". Yes
target-dev-hub Username or alias of the Dev Hub org. Yes
packaging-directory The directory containing the Salesforce project. If not specified, the action will run in the same directory as the action. No
installation-key-bypass Bypass the installation key requirement. (either --installation-key or --installation-key-bypass is required). If you bypass this requirement, anyone can install your package. No
installation-key Installation key for the package version. The default is null. Omit this flag if you specify --installation-key-bypass. No
skip-validation Skip validation during package version creation; you can't promote unvalidated package versions. Skips validation of dependencies, package ancestors, and metadata during package version creation. No
code-coverage Calculate and store the code coverage percentage by running the packaged Apex tests included in this package version. No
async-validation Return a new package version before completing package validations. No
timeout Maximum time in minutes to wait for package creation to complete. Default is 60 minutes (1 hour). No 60
polling-interval Time in seconds between status check attempts. Default is 60 seconds (1 minute). No 60
no-namespace Create the package with no namespace; available only for unlocked packages. This flag is useful when you're migrating an existing org to packages. But use a namespaced package for new metadata. No

📤 Outputs

Name Description
package-version-id The package version ID
package-version-number The package version number
package-report JSON representation of the package report
message The message from the command execution

🚀 Quick Start

Add this workflow to your project in .github/workflows/create-package.yml:

name: Create Salesforce Package Version

on:
  push:
    branches:
      - main
  workflow_dispatch:

env:
  PACKAGE_NAME: MyPackage
  TARGET_DEV_HUB: DevHub

jobs:
  create-package-version:
    name: Create package version
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Create package version
        uses: mathias-moreira/salesforce-ci-packager@v2
        id: create-package-version
        with:
          auth-url: ${{ secrets.AUTH_URL }}
          package-name: ${{ env.PACKAGE_NAME }}
          package-type: Unlocked
          target-dev-hub: ${{ env.TARGET_DEV_HUB }}
          installation-key-bypass: true
          code-coverage: true

      - name: Show package details
        run: |
          echo "Package Version ID: ${{ steps.create-package-version.outputs.package-version-id }}"
          echo "Package Version Number: ${{ steps.create-package-version.outputs.package-version-number }}"

🔧 Under the Hood

This action uses the following Salesforce CLI commands:

  • sf package create: Creates a new package
  • sf package list: Lists all packages in the Dev Hub org
  • sf package version create: Creates a new package version
  • sf package version create report: Checks the status of a package version creation request

For more information about these commands, see the Salesforce CLI Command Reference.

👥 Contributing

We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines on how to contribute to this project, including local development setup and testing.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

📚 Additional Resources


💡 Tip: Store your auth-url as a GitHub secret to keep your credentials secure!

⭐ If you find this action helpful, consider giving it a star on GitHub!

About

GitHub Action to automate the creation of Salesforce Second-Generation Package (2GP) versions in CI/CD workflows. Streamlines package development with configurable validation options, code coverage calculation, and comprehensive status reporting. Supports both local development with act and integration with GitHub Actions.

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages