### Example .releaserc.js Configuration Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt An example configuration file for semantic-release, demonstrating how to define plugins and their options. ```javascript module.exports = { plugins: [ '@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', ['@semantic-release/changelog', { changelogFile: 'CHANGELOG.md' }], '@semantic-release/npm', '@semantic-release/github', ['@semantic-release/git', { assets: ['CHANGELOG.md', 'package.json'] }], ], }; ``` -------------------------------- ### Pre-install Additional Plugins Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Install extra semantic-release plugins not included by default. Version ranges are supported for these plugins. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: extra_plugins: | @semantic-release/changelog@6.0.3 @semantic-release/git@10.0.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Basic Semantic Release Action Usage Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md This is a basic example of how to integrate the Semantic Release Action into your GitHub workflow. Ensure you have set up Semantic Release configuration and necessary secrets in your repository. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Specify Semantic Release Version Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md It is recommended to specify a version range for semantic-release when using semantic-release-action lower than @v4. This example shows how to set the `semantic_version` input parameter. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: semantic_version: 19.0.5 # It is recommended to specify a version range # for semantic-release when using # semantic-release-action lower than @v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Use Shareable Configuration Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Load one or more shareable semantic-release configurations to enforce consistent release standards across projects. Pin versions using `extra_plugins`. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: extends: | @semantic-release/apm-config@^9.0.0 @mycompany/release-config extra_plugins: | @semantic-release/apm-config@^9.0.0 @mycompany/release-config env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Reference semantic-release Configuration Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt This JavaScript configuration file defines the plugin pipeline for semantic-release. It includes plugins for analyzing commits, generating release notes, updating changelogs, and publishing to npm and GitHub. ```javascript // release.config.js module.exports = { dryRun: false, plugins: [ '@semantic-release/commit-analyzer', // determines version bump from commits '@semantic-release/release-notes-generator', // builds release notes ['@semantic-release/changelog', { changelogFile: 'docs/CHANGELOG.md', // writes changelog to docs/ }], '@semantic-release/npm', // publishes to npm '@semantic-release/github', // creates GitHub release ['@semantic-release/git', { assets: ['docs/CHANGELOG.md', 'package.json', 'package-lock.json'], message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}', }], ], }; ``` -------------------------------- ### Add Extra Plugins for Semantic Release Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Specify additional plugins for semantic-release using the 'extra_plugins' parameter. Ensure these plugins are also listed in your semantic-release configuration file. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: # You can specify specifying version range for the extra plugins if you prefer. extra_plugins: | @semantic-release/changelog@6.0.0 @semantic-release/git env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Preview Release with Dry Run Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Execute semantic-release in dry-run mode to preview the version bump and release notes without actually publishing. This overrides the `dryRun` flag in your configuration. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: dry_run: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # Output: logs the would-be version bump and release notes; nothing is published. ``` -------------------------------- ### Configure Single Release Branch (semantic-release < v16) Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Set a single release branch for older versions of semantic-release (prior to v16) using the `branch` input. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: semantic_version: 15.13.28 branch: main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Consuming semantic-release Outputs in GitHub Actions Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Use the `steps.release.outputs` to access metadata after semantic-release completes. Gate downstream steps using `new_release_published` to ensure actions only run when a new version is published. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 id: release # required to reference outputs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # Only runs when a new version was actually published - name: Inspect release outputs if: steps.release.outputs.new_release_published == 'true' run: | echo "Version : ${{ steps.release.outputs.new_release_version }}" # e.g. "2.5.0" echo "Major : ${{ steps.release.outputs.new_release_major_version }}" # e.g. "2" echo "Minor : ${{ steps.release.outputs.new_release_minor_version }}" # e.g. "5" echo "Patch : ${{ steps.release.outputs.new_release_patch_version }}" # e.g. "0" echo "Channel : ${{ steps.release.outputs.new_release_channel }} # e.g. "" (default) or "beta" echo "Git tag : ${{ steps.release.outputs.new_release_git_tag }}" # e.g. "v2.5.0" echo "Git head : ${{ steps.release.outputs.new_release_git_head }} # e.g. "a1b2c3d..." echo "Prev ver : ${{ steps.release.outputs.last_release_version }} # e.g. "2.4.1" echo "Prev tag : ${{ steps.release.outputs.last_release_git_tag }} # e.g. "v2.4.1" - name: Build and push Docker image if: steps.release.outputs.new_release_published == 'true' run: | docker build -t myorg/myapp:${{ steps.release.outputs.new_release_version }} . docker push myorg/myapp:${{ steps.release.outputs.new_release_version }} - name: Release notes preview if: steps.release.outputs.new_release_published == 'true' run: | echo "${{ steps.release.outputs.new_release_notes }}" ``` -------------------------------- ### Run in Subdirectory Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Use `working_directory` to change the directory before executing semantic-release. This is helpful for monorepos where the publishable package is in a sub-folder. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: working_directory: ./packages/my-lib env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Configure Branches for Semantic Release v16+ Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Use the 'branches' parameter to specify release branches for semantic-release versions 16 and above. This supports complex branch configurations including prerelease branches. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: semantic_version: 16 # you can set branches for semantic-release above v16. branches: | [ '+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', { name: 'beta', prerelease: true }, { name: 'alpha', prerelease: true } ] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Using Output Variables in GitHub Actions Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md This snippet demonstrates how to use the output variables from the semantic-release-action to conditionally execute subsequent steps. Ensure the action has an `id` to access its outputs. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 id: semantic # Need an `id` for output variables env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Do something when a new release published if: steps.semantic.outputs.new_release_published == 'true' run: | echo ${{ steps.semantic.outputs.new_release_version }} echo ${{ steps.semantic.outputs.new_release_major_version }} echo ${{ steps.semantic.outputs.new_release_minor_version }} echo ${{ steps.semantic.outputs.new_release_patch_version }} ``` -------------------------------- ### Configure Release Branches Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Define the branches from which releases should be published, supporting complex configurations including prerelease channels for semantic-release v16 and later. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: branches: | [ '+([0-9])?(.{+([0-9]),x}).x', 'main', 'next', { name: 'beta', prerelease: true }, { name: 'alpha', prerelease: true } ] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Extend Semantic Release Configuration Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Use the `extends` option to incorporate existing sharable configurations from semantic-release. This can be combined with `extra_plugins` and allows specifying version ranges for extended configurations. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: # You can extend an existing shareable configuration. # And you can specify version range for the shareable configuration if you prefer. extends: | @semantic-release/apm-config@^9.0.0 @mycompany/override-config env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Run Semantic Release in Dry-Run Mode Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Enable dry-run mode for semantic-release by setting the 'dry_run' parameter to true. This allows testing release generation without publishing. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: dry_run: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Configure Private Packages Registry Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md If publishing to the npm GitHub Packages Registry, configure your package.json with the correct registry URL. This ensures that your private packages are published to the correct location. ```json { "publishConfig": { "registry": "https://npm.pkg.github.com" } } ``` -------------------------------- ### Pin semantic-release Version Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Specify an exact version or a semver range for semantic-release to avoid unexpected changes from upstream updates. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: semantic_version: 24.2.0 # exact pin # semantic_version: ^24 # or a range env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Set Custom Working Directory Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Override the default working directory for semantic-release by specifying a `working_directory`. This is useful for monorepos or when the release process needs to run from a subdirectory. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: # You can select another working directory like a subdirectory for example. working_directory: ./code env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Custom Git Tag Format Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Override the default `v{version}` tag template using `tag_format`. This is essential for monorepos that version multiple packages in a single repository. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: tag_format: my-package-v${version} # e.g. my-package-v1.4.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Toggle CI Environment Enforcement Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Use `ci: false` to disable semantic-release's built-in CI check. This is useful with `dry_run` to simulate releases from pull-request contexts. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: dry_run: true ci: false # allows running outside a recognised CI branch env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Customize Tag Format Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Modify the default Git tag format (`v{version}`) using the `tag_format` option. This is particularly helpful for managing releases in monorepos. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: tag_format: custom-v${version} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Disable CI Support for Semantic Release Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Control CI support for semantic-release using the 'ci' parameter. Setting 'ci' to false can be useful in scenarios like pull request builds where automatic releases are not desired. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: ci: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Override Target Git Repository URL Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Pass a custom repository URL to semantic-release using `repository_url`. This is useful when the action runs in a context where the remote URL differs from the default. ```yaml steps: - uses: actions/checkout@v5 - uses: cycjimmy/semantic-release-action@v6 with: repository_url: https://github.com/myorg/myrepo.git env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Remove GHA Environment Variable Source: https://context7.com/cycjimmy/semantic-release-action/llms.txt Unset the `GITHUB_ACTIONS` environment variable before semantic-release runs. This is required to simulate releases from pull-request branches where semantic-release might otherwise abort. ```yaml steps: - uses: actions/checkout@v5 - name: Temporarily merge PR branch if: github.event_name == 'pull_request' run: | git config --global user.name github-actions git config --global user.email github-actions@github.com git merge --no-ff origin/${{ github.event.pull_request.head.ref }} \ --message "${{ github.event.pull_request.title }}" - uses: cycjimmy/semantic-release-action@v6 with: unset_gha_env: ${{ github.event_name == 'pull_request' }} ci: ${{ github.event_name == 'pull_request' && 'false' || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### Unset GHA Environment Variable Source: https://github.com/cycjimmy/semantic-release-action/blob/main/README.md Set `unset_gha_env` to `true` to unset the `GITHUB_ACTIONS` environment variable. This can be useful for testing scenarios, such as validating PR merges that would result in a valid release. ```yaml steps: - name: Checkout uses: actions/checkout@v5 - name: Temporarily merge PR branch if: ${{ github.event_name == 'pull_request' }} run: | git config --global user.name github-actions git config --global user.email github-actions@github.com git merge --no-ff origin/${{ github.event.pull_request.head.ref }} --message "${{ github.event.pull_request.title }}" - name: Semantic Release uses: cycjimmy/semantic-release-action@v6 with: unset_gha_env: ${{ github.event_name == 'pull_request' }} ci: ${{ github.event_name == 'pull_request' && false || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.