quilla/.github/workflows/release-pipeline.yml

214 строки
5.8 KiB
YAML

name: Release pipeline
on:
push:
branches:
- main
jobs:
version-check:
runs-on: ubuntu-latest
name: Verify version has been increased
outputs:
run_deploy: ${{ steps.verify.outputs.run_deploy }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install necessary package for scripts to run
run: pip install packaging
- name: Verify that the version has been increased
id: verify
run: echo "::set-output name=run_deploy::$(python scripts/version_verification.py $(python scripts/extract_version.py) $(cat VERSION))"
build:
needs: version-check
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.8', '3.9']
name: Testing Quilla with python ${{ matrix.python }}
if: ${{ needs.version-check.outputs.run_deploy == 'yes' }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install firefox
run: sudo apt install firefox
- name: Get geckodriver
run: ./scripts/get_geckodriver.sh
- name: Install wheel
run: pip install wheel
- name: Install all dependencies
run: pip install -e .[all]
- name: Run linter
run: flake8
- name: Run static type checker
run: mypy
release:
needs: build
runs-on: ubuntu-latest
name: Releasing package
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Needed for changelog generation
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install release packages
run: pip install -e .[all]
- name: Ensure clean dist/ and build/ folders
run: rm -rf dist build
continue-on-error: true
- name: Build release
run: python setup.py sdist bdist_wheel
- name: Extract last version tag
run: echo "previous_tag=$(python scripts/extract_version.py)" >> $GITHUB_ENV
- name: Extract wheel artifact name
run: echo "wheel_name=$(echo dist/*.whl)" >> $GITHUB_ENV
- name: Extract tar.gz artifact name
run: echo "tar_name=$(echo dist/*.tar.gz)" >> $GITHUB_ENV
- name: Pull tags from the repo
run: git pull --tags
- name: Generate version changelog for release
run: gitchangelog $previous_tag..HEAD | sed "s/## (unreleased)/Quilla v$(cat VERSION) ($(date +"%Y-%m-%d"))/" > version_changelog.md
- name: Create Github release & upload files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: hub release create -a $wheel_name -a $tar_name -F version_changelog.md $(cat VERSION)
- name: Install Twine
run: pip install twine
- name: Release package
run: twine upload dist/*
changelog-result:
needs: release
runs-on: ubuntu-latest
name: Generating Changelog
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Needed for changelog generation
- name: Create new branch
run: git checkout -b actions/changelog
- name: Set branch upstream
run: git push -u origin actions/changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: pip install -e .[all]
- name: Generate newest changelog
run: gitchangelog $(cat VERSION) > CHANGELOG.md
- name: Make commit for auto-generated changelog
uses: EndBug/add-and-commit@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add: 'CHANGELOG.md'
branch: actions/changelog
message: '!gitchangelog'
- name: Create pull request for the auto generated changelog
run: |
echo "PR_URL=$(gh pr create \
--title "Auto-generated changelog for release $(cat VERSION)" \
--body "This is an auto-generated PR" \
--label documentation)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set pull request to auto-merge as rebase
run: |
gh pr merge $PR_URL \
--auto \
--delete-branch \
--rebase
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs-build:
needs: release
runs-on: ubuntu-latest
name: Build the docs artifact
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install docs packages
run: pip install -e .[docs]
- name: Build documentation
run: DOC_TARGETS=html make docs
- name: Export docs as an artifact
uses: actions/upload-artifact@v2
with:
name: html_docs
path: ./docs/_build/html
docs-release:
needs: docs-build
runs-on: ubuntu-latest
name: Publish the new documentation
steps:
- uses: actions/checkout@v2
with:
ref: gh-pages
- name: Download the doc artifact
uses: actions/download-artifact@v2
with:
name: html_docs
path: ./docs
- name: Release gh-pages
uses: EndBug/add-and-commit@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add: '.'
branch: gh-pages
message: 'chg: updated documentation after release'