Fix test workflow #4
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 and Publish PyMEOS | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
jobs: | |
checks: | |
name: Make checks | |
runs-on: ubuntu-latest | |
outputs: | |
is_alpha: ${{ steps.check_alpha.outputs.is_alpha }} | |
is_beta: ${{ steps.check_beta.outputs.is_beta }} | |
is_rc: ${{ steps.check_rc.outputs.is_rc }} | |
is_prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Check if publishing an alpha version | |
id: check_alpha | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-alpha ]]; then | |
echo "Releasing an alpha version." | |
echo "is_alpha=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_alpha=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check if publishing a beta version | |
id: check_beta | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta ]]; then | |
echo "Releasing a beta version." | |
echo "is_beta=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_beta=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check if publishing a release candidate version | |
id: check_rc | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then | |
echo "Releasing an rc version." | |
echo "is_rc=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_rc=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check if publishing a prerelease version | |
id: check_prerelease | |
run: | | |
is_alpha=${{ steps.check_alpha.outputs.is_alpha }} | |
is_beta=${{ steps.check_beta.outputs.is_beta }} | |
is_rc=${{ steps.check_rc.outputs.is_rc }} | |
if [ "$is_alpha" == "true" ] || [ "$is_beta" == "true" ] || [ "$is_rc" == "true" ]; then | |
echo "Releasing an prerelease version." | |
echo "is_prerelease=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_prerelease=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check package version matches tag | |
run: | | |
tag_version=${GITHUB_REF#refs/tags/v} | |
python_version=$(grep -oP '__version__ = "\K[^"]+' pymeos/__init__.py) | |
if [[ "$tag_version" != "$python_version" ]]; then | |
echo "Tag Version ($tag_version) doesn't match Code Version ($python_version)" | |
echo "::error title=Version mismatch::Tag Version ($tag_version) doesn't match Code Version ($python_version)" | |
exit 1 | |
fi | |
build: | |
name: Build PyMEOS | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
- name: Setup pip | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
- name: Build package | |
run: python -m build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: | | |
./dist/pymeos-*.tar.gz | |
./dist/pymeos-*.whl | |
release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
needs: [ checks, build ] | |
permissions: | |
contents: write | |
steps: | |
- name: Get artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./dist | |
merge-multiple: true | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./dist/* | |
prerelease: ${{ needs.checks.outputs.is_prerelease }} | |
generate_release_notes: true | |
publish: | |
name: Upload to PyPI | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
if: github.repository == 'MobilityDB/PyMEOS' | |
environment: | |
name: pypi | |
url: https://pypi.org/p/pymeos | |
permissions: | |
id-token: write | |
steps: | |
- name: Get artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./dist | |
merge-multiple: true | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |