Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .flake8

This file was deleted.

107 changes: 82 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,112 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
with:
fetch-depth: '0'
- name: Set up Python
uses: actions/setup-python@v2
- uses: astral-sh/setup-uv@v8.2.0
with:
python-version: '3.8.x'
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
run: uv sync --extra dev --frozen
- name: Get next version
uses: anothrNick/github-tag-action@9885a4f9af674ba472de91fb3c0cb033ecb32b7e
uses: anothrNick/github-tag-action@1.75.0
id: bump_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: none
WITH_V: false
RELEASE_BRANCHES: main
DRY_RUN: true
- name: Resolve release version
id: release_version
env:
TAG_VERSION: ${{ steps.bump_version.outputs.tag }}
NEW_TAG_VERSION: ${{ steps.bump_version.outputs.new_tag }}
run: |
current_version="$(uv run python - <<'PY'
import ast

with open("src/leet2git/version.py", encoding="UTF8") as file:
tree = ast.parse(file.read())

for node in tree.body:
if not isinstance(node, ast.Assign):
continue
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "__version__":
print(ast.literal_eval(node.value))
raise SystemExit

raise SystemExit("Could not find __version__")
PY
)"
latest_pypi_version="$(uv run python - <<'PY'
import json
import urllib.request

with urllib.request.urlopen("https://pypi.org/pypi/leet2git/json", timeout=20) as response:
print(json.load(response)["info"]["version"])
PY
)"

release_version="$current_version"
release_reason="none"
if [ "$NEW_TAG_VERSION" != "$TAG_VERSION" ]; then
release_version="$NEW_TAG_VERSION"
release_reason="tag"
elif [ "$current_version" != "$latest_pypi_version" ]; then
release_reason="package-version"
fi

should_release=false
if [ "$release_reason" != "none" ]; then
should_release=true
fi

echo "current_version=$current_version" >> "$GITHUB_OUTPUT"
echo "latest_pypi_version=$latest_pypi_version" >> "$GITHUB_OUTPUT"
echo "version=$release_version" >> "$GITHUB_OUTPUT"
echo "reason=$release_reason" >> "$GITHUB_OUTPUT"
echo "should_release=$should_release" >> "$GITHUB_OUTPUT"

echo "Current version: $current_version"
echo "Latest PyPI version: $latest_pypi_version"
echo "Release version: $release_version"
echo "Release reason: $release_reason"
- name: Update app version
if: ${{ steps.bump_version.outputs.new_tag != steps.bump_version.outputs.tag }}
if: ${{ steps.release_version.outputs.reason == 'tag' }}
run: |
python src/leet2git/version.py ${{ steps.bump_version.outputs.new_tag }}
uv run python src/leet2git/version.py ${{ steps.release_version.outputs.version }}
git config user.email "yurirocha15@gmail.com"
git config user.name "Yuri Rocha"
git add src/leet2git/version.py
git commit -m "bump version to ${{ steps.bump_version.outputs.new_tag }}"
git diff --cached --quiet || git commit -m "bump version to ${{ steps.release_version.outputs.version }}"
- name: Push to protected branch
if: ${{ steps.bump_version.outputs.new_tag != steps.bump_version.outputs.tag }}
uses: CasperWA/push-protected@v2
if: ${{ steps.release_version.outputs.reason == 'tag' }}
uses: CasperWA/push-protected@v2.16.0
with:
token: ${{ secrets.PUSH_TO_PROTECTED_BRANCH }}
branch: main
unprotect_reviews: true
- name: Bump version and push tag
if: ${{ steps.bump_version.outputs.new_tag != steps.bump_version.outputs.tag }}
uses: anothrNick/github-tag-action@9885a4f9af674ba472de91fb3c0cb033ecb32b7e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: none
WITH_V: true
RELEASE_BRANCHES: main
- name: Push release tag
if: ${{ steps.release_version.outputs.should_release == 'true' }}
run: |
tag="v${{ steps.release_version.outputs.version }}"
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
echo "Tag $tag already exists"
else
git tag "$tag"
git push origin "$tag"
fi
- name: Build package
if: ${{ steps.bump_version.outputs.new_tag != steps.bump_version.outputs.tag }}
run: python -m build
if: ${{ steps.release_version.outputs.should_release == 'true' }}
run: uv run python -m build
- name: Publish package
if: ${{ steps.bump_version.outputs.new_tag != steps.bump_version.outputs.tag }}
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ steps.release_version.outputs.should_release == 'true' }}
uses: pypa/gh-action-pypi-publish@v1.14.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v7

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v4.36.2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v4.36.2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v4.36.2
21 changes: 9 additions & 12 deletions .github/workflows/format-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ jobs:
format-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v8.2.0
with:
activate-environment: coding-practice
python-version: 3.8
auto-activate-base: false
enable-cache: true
- name: Set up Python
run: uv python install
- name: Setup
shell: bash -l {0}
run: make setup-dev
- name: Format with black and isort
shell: bash -l {0}
run: uv sync --extra dev --frozen
- name: Format with Ruff
run: make format
- name: Lint with flake8, mypy and pylint
shell: bash -l {0}
run: make lint
- name: Lint with Ruff and ty
run: make lint
16 changes: 7 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ jobs:
unittest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v8.2.0
with:
activate-environment: coding-practice
python-version: 3.8
auto-activate-base: false
enable-cache: true
- name: Set up Python
run: uv python install
- name: Setup
shell: bash -l {0}
run: make setup-dev
run: uv sync --extra dev --frozen
- name: Run unit tests
shell: bash -l {0}
run: make utest
run: make utest
17 changes: 8 additions & 9 deletions .github/workflows/validate-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ jobs:
validate-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
with:
fetch-depth: '0'
- name: Set up Python
uses: actions/setup-python@v2
- uses: astral-sh/setup-uv@v8.2.0
with:
python-version: '3.8.x'
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
run: uv sync --extra dev --frozen
- name: Get next version
uses: anothrNick/github-tag-action@9885a4f9af674ba472de91fb3c0cb033ecb32b7e
uses: anothrNick/github-tag-action@1.75.0
id: bump_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -34,4 +33,4 @@ jobs:
echo "Current tag: ${{ steps.bump_version.outputs.tag }}"
echo "New tag: ${{ steps.bump_version.outputs.new_tag }}"
- name: Build package
run: python -m build
run: uv run python -m build
2 changes: 0 additions & 2 deletions .mypy.ini

This file was deleted.

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ repos:
name: format
language: system
entry: make format
types: [python]
types: [python]
Loading
Loading