Bugfix: GitHub output #33
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
# GitHub Actions Pipeline | ||
name: 'YoYoCICD' | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- yoyo/** | ||
- tests/** | ||
- .github/workflows/** | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- yoyo/** | ||
- tests/** | ||
- .github/workflows/** | ||
# Repo Permissions | ||
permissions: | ||
contents: write | ||
issues: read | ||
checks: write | ||
pull-requests: write | ||
jobs: | ||
Test: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: checkout repo content | ||
uses: actions/checkout@v2 | ||
- name: setup python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.12' | ||
- name: Upgrade package manager | ||
run: python -m pip install -U pip | ||
# Install dependencies | ||
- name: install testing libraries | ||
run: pip install pytest mock codecov pydocstyle pytest-cov pylint pylint_junit | ||
- name: install project dependencies | ||
run: python -m packages.sync | ||
# Run tests | ||
- name: Run tests | ||
run: pytest -v tests/ --doctest-modules --junitxml=unit-testresults.xml --cov=yoyo/ --cov-append --cov-report=xml:xmlcov --cov-report=html:htmlcov | ||
- name: Publish test reuslts | ||
uses: EnricoMi/[email protected] | ||
Build: | ||
needs: Test | ||
runs-on: 'ubuntu-latest' | ||
outputs: | ||
isPR: ${{ steps.check_build.outputs.is_pr }} | ||
VERSION: ${{ steps.get_version.outputs.version }} | ||
steps: | ||
- name: Checkout repo content | ||
uses: actions/checkout@v2 | ||
- name: Install python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.12' | ||
# Install dependencies | ||
- name: Upgrade pip | ||
run: python -m pip install -U pip | ||
- name: Install build dependencies | ||
run: pip install build setuptools | ||
- name: install project dependencies | ||
run: python -m packages.sync | ||
# Build | ||
- name: Build distribution | ||
run: python -m build --wheel | ||
# Artifacts | ||
- name: Check build reason | ||
id: check_build | ||
run: | | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
echo "is_pr=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "is_pr=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Extract version | ||
id: get_version | ||
if: ${{ outputs.isPR }} == 'true' | ||
Check failure on line 101 in .github/workflows/build.yaml GitHub Actions / YoYoCICDInvalid workflow file
|
||
run: | | ||
echo "Getting version from __init__.py..." | ||
VERSION=$(python <<EOF | ||
import re | ||
with open('yoyo/__init__.py', 'r') as file: | ||
data = file.read() | ||
match = re.search(r"__version__ = '\"['\"]", data) | ||
print(match.group(1) if match else '') | ||
EOF | ||
) | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
- name: test | ||
run: | | ||
echo ${{ outputs.VERSION }} | ||
echo ${{ outputs.isPR }} | ||
- name: Create release | ||
uses: ncipollo/[email protected] | ||
if: ${{ outputs.isPR }} == 'true' | ||
with: | ||
tag: ${{ outputs.VERSION }} | ||
allowUpdates: true | ||
replacesArtifacts: true | ||
# # PYPI API Key not yet configured | ||
# Release: | ||
# needs: Build | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Check out code | ||
# uses: actions/checkout@v2 | ||
# - name: Set up Python | ||
# uses: actions/setup-python@v2 | ||
# with: | ||
# python-version: 3.12 | ||
# - name: Install dependencies | ||
# run: | | ||
# python -m pip install --upgrade pip | ||
# pip install setuptools wheel twine | ||
# - name: Build and publish | ||
# env: | ||
# TWINE_USERNAME: __token__ | ||
# TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
# run: | | ||
# python setup.py sdist bdist_wheel | ||
# twine upload dist/* | ||