Skip to content

Release

Release #4

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.1)'
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Generate Release Notes
id: generate_notes
run: |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "## What's Changed" > release_notes.md
# Features
echo "### 🚀 Features" >> release_notes.md
if [ -z "$LAST_TAG" ]; then
git log --pretty=format:"* %s (%h)" --no-merges | grep -i "^feat:" >> release_notes.md || true
else
git log ${LAST_TAG}..HEAD --pretty=format:"* %s (%h)" --no-merges | grep -i "^feat:" >> release_notes.md || true
fi
# Bug Fixes
echo -e "\n### 🐛 Bug Fixes" >> release_notes.md
if [ -z "$LAST_TAG" ]; then
git log --pretty=format:"* %s (%h)" --no-merges | grep -i "^fix:" >> release_notes.md || true
else
git log ${LAST_TAG}..HEAD --pretty=format:"* %s (%h)" --no-merges | grep -i "^fix:" >> release_notes.md || true
fi
# Other Changes
echo -e "\n### 🔧 Other Changes" >> release_notes.md
if [ -z "$LAST_TAG" ]; then
git log --pretty=format:"* %s (%h)" --no-merges | grep -iv "^feat:\|^fix:" >> release_notes.md || true
else
git log ${LAST_TAG}..HEAD --pretty=format:"* %s (%h)" --no-merges | grep -iv "^feat:\|^fix:" >> release_notes.md || true
fi
# Escape content for GitHub Actions
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "RELEASE_NOTES<<$EOF" >> $GITHUB_ENV
cat release_notes.md >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Update version in pyproject.toml
run: |
sed -i "/^\[project\]/,/^\[.*\]/ s/version = \".*\"/version = \"${{ github.event.inputs.version }}\"/" pyproject.toml
- name: Update README version
run: |
sed -i "s|narrative-llm-tools @ git+https://github.com/narrative-io/narrative-llm-tools.git@.*|narrative-llm-tools @ git+https://github.com/narrative-io/narrative-llm-tools.git@v${{ github.event.inputs.version }}|" README.md
- name: Commit version update
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add pyproject.toml README.md
git commit -m "Bump version to ${{ github.event.inputs.version }}"
git push
- name: Create and push tag
run: |
git tag -a v${{ github.event.inputs.version }} -m "Release v${{ github.event.inputs.version }}"
git push origin v${{ github.event.inputs.version }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ github.event.inputs.version }}
name: Release v${{ github.event.inputs.version }}
body: ${{ env.RELEASE_NOTES }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}