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!
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
- π 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
| 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 |
| 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 |
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 }}"This action uses the following Salesforce CLI commands:
sf package create: Creates a new packagesf package list: Lists all packages in the Dev Hub orgsf package version create: Creates a new package versionsf 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.
We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines on how to contribute to this project, including local development setup and testing.
This project is licensed under the MIT License - see the LICENSE file for details.
π‘ 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!