GitHub Actions Certification
Custom Actions
Create GitHub release using GitHub Actions
Automate your GitHub release workflow with GitHub Actions—no more manual tagging or UI clicks. In this tutorial, we’ll use the Troubleshooting JavaScript Actions repository as our example, transforming a once-manual process into a seamless pipeline.
1. Manual Release Workflow
Before automation, releases were created by hand:
- Navigate to Releases in your repo.
- Select an existing tag or create a new one.
- Choose the target branch.
- Write release notes and publish.
For each release, you specify the tag, assign the branch, and craft release notes:
Each published release is tied to a Git tag, pointing to a precise code snapshot. Automating this ensures consistency and saves time.
2. Choosing an Action
GitHub’s Actions Marketplace provides community-maintained workflows. A search for “release” surfaces many options. We’ll use the popular softprops/action-gh-release
action:
Why
softprops/action-gh-release
?
- Automatically creates releases from tags
- Supports asset uploads
- Handles prerequisites (permissions, checks)
3. Minimal Workflow Example
Below is the simplest setup: trigger on semver tags starting with v
and create a release.
name: Create Release
on:
push:
tags:
- "v*.*.*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: softprops/action-gh-release@v2
Semantic Versioning Pattern
Use tag patterns to control when the workflow runs:
Pattern | Matches |
---|---|
v*.*.* | v1.0.0, v2.3.4, etc. |
* | All tags |
4. Adding Assets to Your Release
To upload build artifacts (e.g., binaries, docs), extend the workflow:
name: Create Release with Assets
on:
push:
tags:
- "v*.*.*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Artifact
run: echo ${{ github.sha }} > release_info.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: release_info.txt
5. Implementing the Auto-Release Workflow
- Clone your repo and open it in VS Code.
- Create a new workflow file at
.github/workflows/autorelease.yaml
.
- Paste the following content:
name: Auto Release Workflow
on:
push:
tags:
- "*"
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Release & Upload dist/index.js
uses: softprops/action-gh-release@v2
with:
files: dist/index.js
Permissions Required
The workflow needs contents: write
permission to publish releases and upload assets.
Without it, the release step will fail.
6. Commit, Tag, and Push
git add .github/workflows/autorelease.yaml
git commit -m "feat: add auto release workflow and upload dist/index.js"
git push origin main
Create and push a new tag to trigger the workflow:
git tag v1.0.0
git push origin v1.0.0
7. Verify the Workflow
Navigate to the Actions tab and look for Auto Release Workflow:
Open the run to ensure all steps—checkout, release creation, and asset upload—completed successfully:
8. Review and Publish Your Release
After execution, go to Releases. You’ll see:
- A new release named
v1.0.0
- Release notes from your git commit message
index.js
attached under Assets
To push your Action to the Marketplace, click Edit release and follow the Publish to Marketplace prompts:
Congratulations—you now have a fully automated GitHub release pipeline!
References
- GitHub Actions Documentation
- GitHub Actions Marketplace
- softprops/action-gh-release
- Semantic Versioning
Watch Video
Watch video content