Skip to content

Merge pull request #50 from IBM/chore/security-deps #33

Merge pull request #50 from IBM/chore/security-deps

Merge pull request #50 from IBM/chore/security-deps #33

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to create release for (e.g., v0.5.1)'
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for changelog
- name: Get version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG=${GITHUB_REF#refs/tags/}
fi
VERSION=${TAG#v}
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Validate version matches pyproject.toml
run: |
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
if [ "${{ steps.version.outputs.version }}" != "$PYPROJECT_VERSION" ]; then
echo "Error: Tag version (${{ steps.version.outputs.version }}) does not match pyproject.toml version ($PYPROJECT_VERSION)"
exit 1
fi
echo "Version matches: ${{ steps.version.outputs.version }}"
- name: Get previous tag
id: previous_tag
run: |
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -v "${{ steps.version.outputs.tag }}" | head -n 1)
if [ -z "$PREVIOUS_TAG" ]; then
PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
echo "Previous tag/commit: ${PREVIOUS_TAG}"
- name: Generate changelog
id: changelog
run: |
echo "Generating changelog from ${{ steps.previous_tag.outputs.previous_tag }} to ${{ steps.version.outputs.tag }}"
CHANGELOG=$(git log ${{ steps.previous_tag.outputs.previous_tag }}..${{ steps.version.outputs.tag }} \
--pretty=format:"- %s (%h)" \
--no-merges)
if [ -z "$CHANGELOG" ]; then
CHANGELOG="- Initial release"
fi
# Save to file for GitHub release
cat > changelog.md << EOF
## Changes in ${{ steps.version.outputs.tag }}
$CHANGELOG
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.previous_tag.outputs.previous_tag }}...${{ steps.version.outputs.tag }}
EOF
echo "Changelog generated:"
cat changelog.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body_path: changelog.md
draft: false
prerelease: false