Skip to content

test version release #7

test version release

test version release #7

Workflow file for this run

name: Publish the latest release on PyPI
on:
push:
tags:
- 'v*'
branches:
- main # Restricts the workflow to only run on tags pushed to the main branch
jobs:
validate-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate Tag Format
run: |
TAG_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\-\.]+)?$'
echo "Regex to match: $TAG_REGEX"
TAG="${GITHUB_REF/refs\/tags\//}"
echo "Tag extracted: $TAG"
if [[ "$TAG" =~ $TAG_REGEX ]]; then
echo "Tag format is valid."
else
echo "::error::Tag $TAG does not match the 'vMAJOR.MINOR.PATCH' or 'vMAJOR.MINOR.PATCH-pre-release' format."
exit 1
fi
shell: bash
build-and-package:
needs: validate-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
# Comment out the pytest step
# - name: Run tests
# run: |
# poetry run pytest
- name: Build the distribution
run: poetry build
publish-to-pypi:
needs: build-and-package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build the distribution
run: poetry build
- name: Publish
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_KEY }}
create-github-release:
needs: publish-to-pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Release on GitHub
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: 'Automated release of version ${{ github.ref_name }}'
draft: false
prerelease: false