Skip to content

Release

Release #11

Workflow file for this run

# .github/workflows/release.yml
name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Type of release'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
release-please:
runs-on: ubuntu-latest
# Only run on merged PRs or manual dispatch
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true)
outputs:
releases_created: ${{ steps.manual_release.outputs.releases_created }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: πŸ”§ Setup Node.js (Manual Release)
if: github.event_name == 'workflow_dispatch'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: πŸš€ Create Manual Release Commit
if: github.event_name == 'workflow_dispatch'
id: manual_release
run: |
npm install -g release-please
npm install semver
# Configure git
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Get current version from manifest
CURRENT_VERSION=$(cat .release-please-manifest.json | jq -r '.Website')
echo "Current version: $CURRENT_VERSION"
# Calculate next version based on release type using Node.js
NEXT_VERSION=$(node -e "
const semver = require('semver');
const current = '$CURRENT_VERSION';
const type = '${{ github.event.inputs.release_type }}';
console.log(semver.inc(current, type));
")
echo "Next version will be: $NEXT_VERSION"
# Update version in package.json
cd Website
npm version $NEXT_VERSION --no-git-tag-version
cd ..
# Update manifest file
jq --arg version "$NEXT_VERSION" '.Website = $version' .release-please-manifest.json > temp.json && mv temp.json .release-please-manifest.json
# Generate changelog entry
echo "## [$NEXT_VERSION] - $(date +'%Y-%m-%d')" > temp_changelog.md
echo "" >> temp_changelog.md
echo "### Changed" >> temp_changelog.md
echo "- Manual ${{ github.event.inputs.release_type }} release" >> temp_changelog.md
echo "" >> temp_changelog.md
# Prepend to existing changelog if it exists
if [ -f "Website/CHANGELOG.md" ]; then
cat temp_changelog.md Website/CHANGELOG.md > temp_full_changelog.md
mv temp_full_changelog.md Website/CHANGELOG.md
else
mv temp_changelog.md Website/CHANGELOG.md
fi
# Commit and push changes
git add .
git commit -m "chore(release): release $NEXT_VERSION
Release type: ${{ github.event.inputs.release_type }}
Previous version: $CURRENT_VERSION
New version: $NEXT_VERSION"
git push origin HEAD
echo "releases_created=true" >> $GITHUB_OUTPUT
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: πŸ“ Manual Release Summary
if: github.event_name == 'workflow_dispatch'
run: |
echo "βœ… Manual release commit created with type: ${{ github.event.inputs.release_type }}"
echo "🏷️ New version: ${{ steps.manual_release.outputs.version }}"
echo "πŸ“ Changes have been committed and pushed to the current branch."
echo "πŸ”— View the commit: https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)"