Set up a GitHub Actions workflow to create releases automatically when pushing version tags.
This guide shows how to create a GitHub Actions workflow that automatically creates a release whenever you push a version tag.
Prerequisites
Before starting, make sure you have:
-
A GitHub Repository — Your project should already be on GitHub.
-
A GitHub Personal Access Token (PAT) — Needed for the workflow to publish releases.
- Go to GitHub Settings → Developer settings → Personal access tokens.
- Click Generate new token and select the
reposcope. - Store the token as a repository secret (never hardcode it in workflows):
- Go to your repository’s Settings.
- Select Secrets and variables → Actions → New repository secret.
- Name it (e.g.,
GH_TOKEN) and paste your token. - Click Add secret.
-
Basic GitHub Actions Knowledge — If you're new, check the GitHub Actions docs first.
Creating the Workflow
Create a .github/workflows/create-release.yml file in your repository:
name: Create Release on Tag Push
on:
push:
tags:
- "v*"
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GH_TOKEN }}
prerelease: false
How It Works
- Trigger — Runs when a tag starting with
vis pushed (e.g.,v1.0.4). - Action Used — The
marvinpinto/action-automatic-releasesaction handles the release creation process. - Key Inputs:
repo_token— Your GitHub secret for authentication.prerelease— Set tofalsefor stable releases.
When you push a tag like v1.2.0, GitHub Actions will:
- Detect the new tag.
- Run the workflow.
- Create a release associated with that tag.