Skip to content

Add tagging to pipeline #423

Add tagging to pipeline

Add tagging to pipeline #423

Workflow file for this run

# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Deploy
on:
push:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
release-check:
runs-on: ubuntu-20.04
continue-on-error: ${{ startsWith(github.event.ref,'refs/heads/') }}
steps:
- uses: actions/checkout@v3
- name: fetch all tags # need annotated tags for release checklist
run: |
git fetch --force --tags --depth=1
- name: For a dry run, don't verify tags and documentation
if: ${{ ! startsWith(github.event.ref, 'refs/tags/') }}
run: |
echo "EXTRA_CHECKLIST_ARGS=--no-verify-tags --no-verify-docs-next-version" >> $GITHUB_ENV
- name: Run release_checklist
run: |
admin/release_checklist $EXTRA_CHECKLIST_ARGS 7.0+main
deploy:
runs-on: ubuntu-20.04
needs: release-check
env:
FORCE_COLOR: "1"
PYTHON_VERSION: "3.8"
CC: "gcc-8"
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v3
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('noxfile.py', 'doc/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install build commands and GCC
run: |
sudo apt update
sudo apt-get install -y \
make \
ninja-build \
$CC \
$(echo $CC | sed -e 's/gcc/g\+\+/')
sudo apt-get clean
- name: Install libxml2
run: |
sudo apt-get install -y libxml2-utils
sudo apt-get clean
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Lint files
run: |
nox --non-interactive --session lint
- name: Test with pytest
run: |
nox --non-interactive --session "tests_compiler($CC)"
- name: Generate documentation
run: |
nox --non-interactive --session doc
- name: Test bundle of app
run: |
nox --non-interactive --session bundle_app
- name: Build wheel
run: |
nox --non-interactive --session build_wheel
- name: Check wheel
run: |
nox --non-interactive --session check_wheel
- name: Upload distribution
if: ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/**
- name: Apply new tag if version is bumped
if: ${{ success() && (github.event.ref == 'refs/heads/main') }}
run: |
set -e
git config --global user.email "[email protected]"
git config --global user.name "gcovr authors"
# Get the version
Version="$(sed -n 's/__version__.*"\(.*\)"/\1/ p' gcovr/version.py)"
# Try to create the tag and print the output. It's only pushed if it's a real release
git tag -a "$Version" -m "$Version ($(date -Iminutes))"
git tag --list -n "$Version"
# Check if it is a new release
if echo "$Version" | grep -E '^\d+\.\d+$'; then
echo "New version bumped"
git push origin "refs/tags/$Version"
else
echo "Skip pushing tag for development build"
fi
- name: Publish
if: ${{ success() && startsWith(github.event.ref,'refs/tags/') }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m nox --session upload_wheel