Skip to content

add release workflow with tag-push trigger and overwrite support, fix… #1

add release workflow with tag-push trigger and overwrite support, fix…

add release workflow with tag-push trigger and overwrite support, fix… #1

Workflow file for this run

name: Release

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 55, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.PYPI_API_TOKEN != ''
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Build package
run: python -m build
- name: Delete existing release (overwrite support)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${{ steps.tag.outputs.version }}"
if gh release view "$tag" > /dev/null 2>&1; then
echo "Release $tag already exists, deleting for overwrite..."
gh release delete "$tag" --yes --cleanup-tag=false
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${{ steps.tag.outputs.version }}"
gh release create "$tag" dist/* \
--title "codet $tag" \
--generate-notes
- name: Publish to PyPI
if: ${{ secrets.PYPI_API_TOKEN != '' }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload dist/* --skip-existing