Optimize Your CI/CD Pipeline
Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.
name: 'Usage of release-action GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
artifacts: "release.tar.gz,foo/*.txt"
bodyFile: "body.md"
Release Action
An action which manages a GitHub release
What is Release Action?
The Release Action in GitHub Actions is set up to automate the creation of releases in your GitHub repository. It can also, optionally, upload an artifact to the newly created release, making it immediately available to users and other automated processes.
How to Update an Existing Release
To enable the option of updating an existing release rather than creating a new one, you can use the allowUpdates
flag in your GitHub Actions setup. This can be particularly useful for appending additional information or artifacts to an existing release. Here’s how you can configure this setting:
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
In this configuration, if the release tagged as ${{ github.ref }}
already exists, the action will update that release instead of creating a new one.
How to Handle Artifact Upload Errors
To ensure that your release process is robust and all artifacts are properly uploaded, you can use the artifactErrorsFailBuild
flag. Setting this flag to true will cause the build to fail if there are any errors during the reading or uploading of artifacts. This is important for maintaining the integrity of the release process. Here’s how you can set it:
- uses: ncipollo/release-action@v1
with:
artifactErrorsFailBuild: true
How to Specify Artifacts for Upload
To upload specific artifacts to your release, you can utilize the artifacts
input within your GitHub Actions configuration. This input allows you to specify a single path or a comma-delimited list of paths or globs, enabling dynamic inclusion of build artifacts in your release. Here’s an example of how to set this up:
- uses: ncipollo/release-action@v1
with:
artifacts: 'path/to/artifact.zip, path/to/another/artifact*.zip'
In the artifacts field, you specify the paths to the artifacts you wish to upload. This can be a direct path to a file or a pattern that matches multiple files (glob pattern). This flexibility allows you to include exactly what is necessary for the release, ensuring that all relevant build outputs are part of the release package.
How to Set the Release Body
To include a detailed description or release notes with your release, you can utilize the body parameter in your GitHub Actions configuration. This parameter allows you to add comprehensive information that will appear on the GitHub release page, ensuring that all necessary details about the release are communicated effectively to users. Here’s how you can set this up:
- uses: ncipollo/release-action@v1
with:
body: 'Detailed release notes or description here'
How to Handle Draft Releases
To create a release as a draft in GitHub Actions, which remains hidden from the public until you decide to publish it manually, you can use the draft input. Draft releases are particularly useful for staging and finalizing the details of a release before it goes live. Here’s how you can configure a draft release within your GitHub Actions workflow:
- uses: ncipollo/release-action@v1
with:
draft: true
release_name: Draft Release ${{ github.ref }}
In this configuration:
- The draft input is set to true, which means the release will be created as a draft. This draft release will not be visible to the public until it is explicitly published, either through the GitHub UI or via another action in the workflow.
- The release_name and body are configured to indicate that this is a draft and to provide any initial details that should be included in the draft release notes.