ci: add permissions for semantic release #360
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Semantic Release | |
# on: | |
# push: | |
# branches: [main] | |
# pull_request: | |
# branches: [main] | |
# Run a quality check for every commit. | |
# Semantic-release will only run on the main branch to publish new versions | |
on: [push, pull_request] | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install Python Poetry | |
uses: abatilo/actions-poetry@v2.1.0 | |
with: | |
poetry-version: 1.3.2 | |
- name: Configure poetry | |
shell: bash | |
run: python -m poetry config virtualenvs.in-project true | |
- name: View poetry version | |
run: poetry --version | |
- name: Install dependencies and pre-commit | |
run: python -m poetry install | |
- uses: pre-commit/action@v3.0.0 | |
- name: Test with pytest | |
env: | |
FINARY_EMAIL: ${{ secrets.FINARY_EMAIL }} | |
FINARY_PASSWORD: ${{ secrets.FINARY_PASSWORD }} | |
run: python -m poetry run pytest | |
- uses: pre-commit-ci/lite-action@v1.0.1 | |
if: always() | |
semantic-release: | |
needs: pre-commit | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Python Semantic Release | |
id: release | |
uses: python-semantic-release/python-semantic-release@v8.0.6 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
if: steps.release.outputs.released == 'true' | |
# Use the traditional API Token instead of the new trusted auth method for simplicity | |
# See https://github.com/pypa/gh-action-pypi-publish#specifying-a-different-username | |
# with: | |
# password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Publish package distributions to GitHub Releases | |
uses: python-semantic-release/upload-to-gh-release@main | |
if: steps.release.outputs.released == 'true' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} |