Test Release Workflow on Release Branch #1
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: Test Release Workflow on Release Branch | |
on: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- release # Change from main to release for testing | |
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\-\.]+)?$' | |
TAG="${GITHUB_REF/refs\/tags\//}" | |
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 | |
shell: bash | |
build-and-test: | |
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 | |
- name: Run tests | |
run: | | |
poetry run pytest | |
dry-run-publish: | |
needs: build-and-test | |
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: Dry run publish to PyPI | |
run: poetry publish --dry-run | |
# This step simulates the publishing process without making actual changes | |
# The GitHub release creation is commented out to avoid creating releases during tests | |
# create-github-release: | |
# needs: dry-run-publish | |
# 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: 'Test automated release of version ${{ github.ref_name }}' | |
# draft: false | |
# prerelease: false |