chore: Update permissions in ci.yml #12
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: "CI" | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
name: "Build" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install hatch | |
run: | | |
python -m pip install hatch | |
- name: Lint | |
run: hatch run lint:check | |
- name: Tests | |
run: hatch run +py=${{ matrix.python-version }} test:test | |
- name: Build | |
run: hatch build | |
release: | |
name: "Release" | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Python Semantic Release | |
uses: python-semantic-release/python-semantic-release@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update Version with Hatch | |
if: steps.release.outputs.released == 'true' | |
run: | | |
echo "Updating version to ${{ steps.release.outputs.version }}" | |
hatch version ${{ steps.release.outputs.version }} | |
- name: Install hatch | |
run: | | |
python -m pip install hatch | |
- name: Publish on PyPI | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.release.outputs.released == 'true' | |
run: hatch publish | |
env: | |
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }} | |
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }} |