This document outlines the requirements and implementation details for the Release Management workflow.
The Release Management workflow is responsible for collecting changesets, determining the appropriate version bump (major, minor, patch), updating version numbers in files, generating changelogs, and initiating the build and deployment processes.
- When a PR from develop to main is merged
- Manual trigger via GitHub Actions UI
- Scheduled trigger (e.g., weekly/monthly)
The workflow performs the following steps:
- Checkout Code: Checks out the appropriate branch based on the trigger.
- Setup Node.js: Sets up Node.js environment.
- Install Dependencies: Installs npm dependencies.
- Check for Changesets: Verifies that there are changesets to process.
- Determine Version Bump: Analyzes changesets to determine the appropriate version bump (major, minor, patch).
- Update Changelogs: Updates the changelog files with the new version information.
- Generate Release Notes: Generates release notes from changesets or extracts them from the PR body.
- Commit Changes: Commits the version bump and changelog updates to the appropriate branch.
- Create and Push Tag: Creates a Git tag for the new version.
- Create GitHub Release: Creates a GitHub release with the generated release notes.
- Delete Processed Changesets: Removes the processed changesets from the main branch.
- Sync Main to Develop: Merges changes from main back to develop to ensure both branches are in sync after a release.
Changesets follow this lifecycle:
- Automatic Creation: Changesets are automatically generated when PRs are merged to the develop branch.
- Accumulation: These changeset files accumulate in the develop branch until a release is ready.
- Release Preparation: When a PR from develop to main is created, the changesets are used to generate release notes.
- Release: When the PR is merged, the workflow:
- Bumps the version based on the changesets
- Updates changelogs
- Creates a GitHub release
- Deletes the changeset files from the main branch
- Syncs the main branch back to develop, which also removes the changesets from develop
This ensures that changesets are properly tracked, used for release notes, and then cleaned up from both branches after a release is complete.
The workflow uses a temporary directory (/tmp/release-notes/) outside the repository to store release notes during processing. This prevents Git from tracking these temporary files and avoids issues with .gitignore.
The Release Management workflow works in tandem with the Changeset Generation workflow:
- The Changeset Generation workflow creates changesets for merged PRs
- It also creates or updates a release PR from develop to main
- The release PR contains formatted release notes from all changesets
- When the release PR is merged to main, the Release Management workflow is triggered
- It extracts the release notes from the PR body and uses them for the GitHub release
- After the release is created, all changesets are deleted to prevent duplication in future releases
This integration ensures a smooth, automated release process with minimal manual intervention and accurate changelog entries.
name: Release Management
on:
pull_request_target:
types: [closed]
branches:
- main
workflow_dispatch:
inputs:
release_type:
description: 'Force a specific release type (leave empty for auto-detection)'
required: false
type: choice
options:
- auto
- major
- minor
- patch
default: 'auto'
target_branch:
description: 'Target branch for manual release (usually develop)'
required: false
default: 'develop'
schedule:
# Run on the 1st and 15th of each month
- cron: '0 0 1,15 * *'
jobs:
prepare-release:
# Only run if:
# 1. PR from develop to main is merged, OR
# 2. Manually triggered, OR
# 3. Scheduled run
if: (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'develop') || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
# Checkout code
# Setup Node.js
# Install dependencies
# Extract release notes from PR body or generate them
# Determine version bump
# Update version numbers
# Generate changelog
# Build dependencies
# Create GitHub release
# Archive changesets- Decide on the frequency of releases
- Determine how to handle emergency/hotfix releases
- Create scripts for version bumping and changelog generation
- Set up test environment for validating releases
- Consider how to handle release notes for different audiences (developers vs. users)
- Plan for handling release candidates or beta releases