Skip to content

fix: resolve release workflow issues for branch protection and build … #3

fix: resolve release workflow issues for branch protection and build …

fix: resolve release workflow issues for branch protection and build … #3

Workflow file for this run

# Automated Changelog Generation and Release Creation
#
# Purpose: Automatically generates a CHANGELOG.md file based on conventional commits
# and creates GitHub releases with proper versioning.
#
# Triggers:
# - Push to main branch (automatic)
# - Manual workflow dispatch (on-demand)
#
# Features:
# - Uses conventional commits to determine version bumps
# - Generates changelog in Angular preset format
# - Creates semantic version tags (v1.2.3)
# - Publishes GitHub releases with changelog content
# - Commits changelog updates back to repository
#
# Required permissions:
# - contents: write (to push changelog commits)
# - pull-requests: write (for PR interactions)
name: Generate Changelog
on:
push:
branches:
- main
workflow_dispatch: # Allow manual trigger from GitHub UI
# Prevent multiple changelog generations at the same time
concurrency:
group: changelog-${{ github.ref }}
cancel-in-progress: false # Don't cancel changelog generation
permissions:
contents: write # Required to push commits and create tags
pull-requests: write # Required for PR-related operations
jobs:
changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch complete history for accurate changelog generation
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate changelog
uses: TriPSs/conventional-changelog-action@v5
id: changelog
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Commit message format for changelog updates
git-message: 'chore(release): update CHANGELOG.md for {version}'
# Bot identity for commits
git-user-name: 'zopio-bot'
git-user-email: 'bot@zopio.dev'
# Use Angular commit convention for parsing
preset: 'angular'
# Version tags will be formatted as v1.2.3
tag-prefix: 'v'
# Output changelog to root directory
output-file: 'CHANGELOG.md'
# Include all releases in changelog (0 = all)
release-count: 0
# Update package.json version
skip-version-file: false
# Skip commit and tag creation - we'll handle this via PR
skip-commit: true
skip-tag: true
# Generate GitHub Action summary
create-summary: true
# Create a new branch for the changelog update
- name: Create changelog branch
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: |
git config --local user.email "bot@zopio.dev"
git config --local user.name "zopio-bot"
BRANCH_NAME="changelog-update-${{ steps.changelog.outputs.version }}"
git checkout -b $BRANCH_NAME
git add CHANGELOG.md package.json
git commit -m "chore(release): update changelog for v${{ steps.changelog.outputs.version }}"
git push origin $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
# Create PR for changelog update
- name: Create Pull Request
if: ${{ steps.changelog.outputs.skipped == 'false' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `chore(release): update changelog for v${{ steps.changelog.outputs.version }}`,
head: process.env.BRANCH_NAME,
base: 'main',
body: `## Changelog Update
This PR updates the CHANGELOG.md for version v${{ steps.changelog.outputs.version }}.
### Changes included:
- Updated CHANGELOG.md with latest changes
- Bumped version in package.json to ${{ steps.changelog.outputs.version }}
### Release notes:
${{ steps.changelog.outputs.clean_changelog }}
---
*This PR was automatically generated by the changelog workflow.*`
});
core.setOutput('pull-request-number', pr.number);
core.setOutput('pull-request-url', pr.html_url);
# Create GitHub release after PR is created
- name: Create Release
if: ${{ steps.changelog.outputs.skipped == 'false' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog.outputs.tag }} # e.g., v1.2.3
release_name: ${{ steps.changelog.outputs.tag }} # Release title
body: ${{ steps.changelog.outputs.clean_changelog }} # Changelog content for this release
draft: true # Create as draft until PR is merged
prerelease: false # Mark as stable release