Skip to content

Merge pull request #225 from jmuelbert/dependabot/github_actions/gith… #167

Merge pull request #225 from jmuelbert/dependabot/github_actions/gith…

Merge pull request #225 from jmuelbert/dependabot/github_actions/gith… #167

Workflow file for this run

---
# SPDX-FileCopyrightText: Jürgen Mülbert
#
# SPDX-License-Identifier: EUPL-1.2
#
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: "CI"
on: # yamllint disable-line rule:truthy
push:
branches: [main, develop, release]
pull_request:
types: [opened, reopened]
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
defaults:
run:
shell: bash
env:
FORCE_COLOR: "1"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
environment:
name: release
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: "🧰 Checkout Source Code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: "⚙️️ Set up Python"
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
# Read python version from a file .python-version
python-version-file: ".standard-python-version"
check-latest: true
cache: pip
- name: "⚙️️ Get full Python version"
id: full-python-version
run: |
echo version="$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> "$GITHUB_OUTPUT"
- name: "🧰 Install Hatch"
run: pip install --upgrade hatch
- name: "⚙️️ Check Version"
id: check-version
run: |
[[ "$(hatch version)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo "prerelease=true" >> "$GITHUB_OUTPUT"
- name: "🚧 Build and Publish"
run: hatch build
- name: "📦 Create Release"
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: steps.check-version.outputs.prerelease == 'true'
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: hatch publish
# https://github.com/marketplace/actions/alls-green#why
release-all-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- release
runs-on: ubuntu-latest
steps:
- name: "Decide whether the needed jobs succeeded or failed"
uses: re-actors/alls-green@223e4bb7a751b91f43eda76992bcfbf23b8b0302 # v1.2.2
with:
jobs: ${{ toJSON(needs) }}