mirror of
https://github.com/creyD/creyPY.git
synced 2026-04-12 19:30:30 +02:00
111 lines
3.1 KiB
YAML
111 lines
3.1 KiB
YAML
name: Lint, Test, Tag & Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- dev
|
|
paths-ignore:
|
|
- "**/.gitignore"
|
|
- "**/.vscode/**"
|
|
- "**/README.md"
|
|
- "**/CHANGELOG.md"
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- dev
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: psf/black@stable
|
|
with:
|
|
options: "-l 100 --exclude '/.venv/|/__init__.py'"
|
|
- uses: creyD/autoflake_action@master
|
|
with:
|
|
no_commit: True
|
|
options: --in-place --remove-all-unused-imports -r --exclude **/__init__.py,**/db/models.py,
|
|
- uses: stefanzweifel/git-auto-commit-action@v5
|
|
with:
|
|
commit_message: Adjusted files for isort & autopep
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
needs: lint
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
- run: python -m pip install --upgrade pip
|
|
- run: python -m pip install -r requirements.txt
|
|
- run: python test.py
|
|
|
|
tag_and_publish:
|
|
runs-on: ubuntu-latest
|
|
if: github.head_ref == 'master' || github.head_ref == 'dev'
|
|
needs: test
|
|
permissions:
|
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
contents: write # for the tags
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
ref: ${{ github.head_ref }}
|
|
fetch-depth: 0
|
|
|
|
- name: setup git
|
|
run: |
|
|
git config --local user.email "15138480+creyD@users.noreply.github.com"
|
|
git config --local user.name "creyD"
|
|
|
|
- name: Set version format
|
|
id: set_version
|
|
run: |
|
|
if [[ "${{ github.head_ref }}" == "master" ]]; then
|
|
echo "V_FORMAT=${major}.${minor}.${patch}" >> $GITHUB_ENV
|
|
elif [[ "${{ github.head_ref }}" == "dev" ]]; then
|
|
echo "V_FORMAT=${major}.${minor}.${patch}-prerelease${increment}" >> $GITHUB_ENV
|
|
fi"
|
|
|
|
- name: get version format
|
|
run: echo "${{ steps.set_version.outputs.V_FORMAT }}" >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Git Version
|
|
uses: PaulHatch/semantic-version@v5.4.0
|
|
id: git_version
|
|
with:
|
|
tag_prefix: ""
|
|
major_pattern: "breaking:"
|
|
minor_pattern: "feat:"
|
|
enable_prerelease_mode: false
|
|
version_format: "${major}.${minor}.${patch}-prerelease${increment}"
|
|
|
|
- name: Create & Push Tag
|
|
if: github.head_ref == 'master' || github.head_ref == 'dev'
|
|
run: |
|
|
git tag ${{ steps.git_version.outputs.version }}
|
|
git push origin ${{ steps.git_version.outputs.version }}
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.build.txt
|
|
python setup.py sdist bdist_wheel
|
|
|
|
- name: Build and publish
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
user: __token__
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|