add PyZodBaseDataclass
...
#6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
- "[0-9]+.[0-9]+.[0-9]+a[0-9]+" | |
- "[0-9]+.[0-9]+.[0-9]+b[0-9]+" | |
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" | |
env: | |
PACKAGE_NAME: "pyzod" | |
OWNER: "programming-with-ia" | |
jobs: | |
details: | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.release.outputs.new_version }} | |
suffix: ${{ steps.release.outputs.suffix }} | |
tag_name: ${{ steps.release.outputs.tag_name }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Extract tag and Details | |
id: release | |
run: | | |
if [ "${{ github.ref_type }}" = "tag" ]; then | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}') | |
SUFFIX=$(echo $TAG_NAME | grep -oP '[a-z]+[0-9]+' || echo "") | |
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT" | |
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT" | |
echo "Version is $NEW_VERSION" | |
echo "Suffix is $SUFFIX" | |
echo "Tag name is $TAG_NAME" | |
else | |
echo "No tag found" | |
exit 1 | |
fi | |
check_pypi: | |
needs: details | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch information from PyPI | |
run: | | |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}") | |
latest_previous_version=$(echo $response | grep -oP '"releases":\{"\K[^"]+' | sort -rV | head -n 1) | |
if [ -z "$latest_previous_version" ]; then | |
echo "Package not found on PyPI." | |
latest_previous_version="0.0.0" | |
fi | |
echo "Latest version on PyPI: $latest_previous_version" | |
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV | |
- name: Compare versions and exit if not newer | |
run: | | |
NEW_VERSION=${{ needs.details.outputs.new_version }} | |
LATEST_VERSION=$latest_previous_version | |
if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then | |
echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI." | |
exit 1 | |
else | |
echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI." | |
fi | |
setup_and_build: | |
needs: [details, check_pypi] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Bump version | |
run: | | |
NEW_VERSION="${{ needs.details.outputs.new_version }}" | |
sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" $GITHUB_WORKSPACE/pyproject.toml | |
- name: Install dependencies | |
run: uv sync | |
- name: Build source and wheel distribution | |
run: | | |
uv build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
pypi_publish: | |
name: Upload release to PyPI | |
needs: [setup_and_build, details] | |
runs-on: ubuntu-latest | |
environment: | |
name: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Publish to PyPI | |
run: | | |
uv publish | |
github_release: | |
name: Create GitHub Release | |
needs: [setup_and_build, details] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch full history to avoid issues with tags and branches | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- name: Create GitHub Release | |
id: create_release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes | |
bump_version: | |
needs: [details, github_release, pypi_publish] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch full history to avoid issues with tags and branches | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ env.OWNER }}/pyzod.git | |
- name: Bump version | |
run: | | |
NEW_VERSION="${{ needs.details.outputs.new_version }}" | |
sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" $GITHUB_WORKSPACE/pyproject.toml | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Bumping version to ${{ needs.details.outputs.new_version }} | |
branch: bump-version-${{ needs.details.outputs.new_version }} | |
file_pattern: "pyproject.toml" | |
skip_dirty_check: true | |
create_branch: true |