mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 14:24:31 +00:00
118 lines
2.8 KiB
YAML
118 lines
2.8 KiB
YAML
name: Publish
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["CI"]
|
|
types: [completed]
|
|
branches: [master]
|
|
|
|
jobs:
|
|
version-check:
|
|
name: Version Check
|
|
if: github.event.workflow_run.conclusion == 'success'
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
outputs:
|
|
version: ${{ steps.version.outputs.value }}
|
|
is-new: ${{ steps.tag.outputs.is-new }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Read version
|
|
id: version
|
|
run: |
|
|
value=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
|
|
echo "value=$value" >> $GITHUB_OUTPUT
|
|
|
|
- name: Check tag
|
|
id: tag
|
|
run: |
|
|
if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.value }}" | grep -q .; then
|
|
echo "is-new=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "is-new=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build:
|
|
name: Build
|
|
needs: version-check
|
|
if: needs.version-check.outputs.is-new == 'true'
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- uses: actions/setup-python@v6.2.0
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- uses: astral-sh/setup-uv@v7.6.0
|
|
|
|
- run: uv build
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: dist
|
|
path: dist/*
|
|
|
|
publish:
|
|
name: Publish to PyPI
|
|
needs: [version-check, build]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
environment:
|
|
name: pypi
|
|
url: https://pypi.org/project/pyfragment/
|
|
permissions:
|
|
id-token: write
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@v8.0.1
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- uses: pypa/gh-action-pypi-publish@v1.13.0
|
|
|
|
release:
|
|
name: GitHub Release
|
|
needs: [version-check, build]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/download-artifact@v8.0.1
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Extract latest changelog entry
|
|
id: changelog
|
|
run: |
|
|
body=$(awk '/^## \[/{if(found) exit; found=1; next} found{print}' CHANGELOG.md)
|
|
echo "body<<EOF" >> $GITHUB_OUTPUT
|
|
echo "$body" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
- uses: softprops/action-gh-release@v2.6.1
|
|
with:
|
|
tag_name: v${{ needs.version-check.outputs.version }}
|
|
name: v${{ needs.version-check.outputs.version }}
|
|
files: dist/*
|
|
body: ${{ steps.changelog.outputs.body }}
|
|
make_latest: true
|