Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 16 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
default: "v0.1.0"

publish_pypi:
description: "Publish package to PyPI"
type: boolean
required: true
default: true
push:
branches:
- main

permissions:
contents: write
Expand All @@ -38,16 +29,6 @@ jobs:
python-version: "3.12"
cache: pip

- name: Validate version format
run: |
VERSION="${{ github.event.inputs.version }}"
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format: $VERSION"
echo "Expected: vX.Y.Z"
exit 1
fi
echo "Version format valid: $VERSION"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -59,20 +40,27 @@ jobs:
- name: Verify package
run: twine check dist/*

- name: Get latest tag
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Latest tag: $TAG"

- name: Generate release notes
id: notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
PREV_TAG=$(git describe --tags --abbrev=0 --exclude="${{ steps.get_tag.outputs.tag }}" 2>/dev/null || echo "")

if [ -z "$PREV_TAG" ]; then
LOG=$(git log --max-count=50 --pretty=format:"- %s")
else
LOG=$(git log ${PREV_TAG}..HEAD --max-count=100 --pretty=format:"- %s")
LOG=$(git log ${PREV_TAG}..${{ steps.get_tag.outputs.tag }} --max-count=100 --pretty=format:"- %s")
fi

{
echo 'notes<<EOF'
echo "# fognode ${{ github.event.inputs.version }}"
echo "# fognode ${{ steps.get_tag.outputs.tag }}"
echo
echo "## Changes"
echo
Expand All @@ -91,37 +79,17 @@ jobs:
echo 'EOF'
} >> "$GITHUB_OUTPUT"

- name: Check if tag exists
id: check_tag
run: |
TAG="${{ github.event.inputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists"
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Create tag
if: steps.check_tag.outputs.exists == 'false'
run: |
TAG="${{ github.event.inputs.version }}"
git tag "$TAG"
git push origin "$TAG"

- name: Create GitHub release
if: steps.check_tag.outputs.exists == 'false'
- name: Create or update GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
name: fognode ${{ github.event.inputs.version }}
tag_name: ${{ steps.get_tag.outputs.tag }}
name: fognode ${{ steps.get_tag.outputs.tag }}
body: ${{ steps.notes.outputs.notes }}
generate_release_notes: false
files: |
dist/*

- name: Publish to PyPI
if: github.event.inputs.publish_pypi == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
Expand Down
Loading