update workflow test #71
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: Publish the latest release on PyPI | |
on: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- release # Restricts the workflow to only run on tags pushed to the release branch | |
workflow_dispatch: # allows manual control | |
inputs: | |
version: | |
description: 'Override the version number' | |
required: false | |
rollback: | |
description: 'Trigger a rollback to the previous stable version' | |
required: false | |
default: false | |
jobs: | |
validate-tag: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
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 | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Poetry | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Change to the lightrag directory and install dependencies | |
run: | | |
cd lightrag | |
poetry install --no-dev | |
- name: Build the distribution | |
run: | | |
cd lightrag | |
poetry build | |
- name: Upload distribution for publishing | |
uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: lightrag/dist/ | |
dry-run-publish: | |
needs: build-and-package | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Download distribution | |
uses: actions/download-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
- name: Install Poetry and perform dry run publish | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
cd dist | |
poetry publish --dry-run -v | |
publish-to-pypi: | |
needs: | |
- validate-tag | |
- build-and-package | |
- dry-run-publish | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Download distribution | |
uses: actions/download-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
- name: Install Poetry and publish to PyPI | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
cd dist | |
poetry publish --username __token__ --password ${{ secrets.PYPI_KEY }} --verbose | |
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 | |
rollback: | |
needs: publish-to-pypi | |
if: ${{ github.event.inputs.rollback == 'true' }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Rollback to previous stable version | |
run: | | |
echo "Rolling back to previous stable version..." | |
# Add rollback logic here |