diff --git a/.editorconf b/.editorconf new file mode 100644 index 0000000..6ed9e73 --- /dev/null +++ b/.editorconf @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.py] +charset = utf-8 +indent_style = space +indent_size = 4 +max_line_length = 100 diff --git a/.github/workflows/release-python.yaml b/.github/workflows/release-python.yaml new file mode 100644 index 0000000..11237f3 --- /dev/null +++ b/.github/workflows/release-python.yaml @@ -0,0 +1,43 @@ +name: "[auto] release-python" + +on: + push: + tags: + - v.* + +env: + PYTHON_VERSION: "3.10" + +jobs: + build: + name: Release new version to PyPI + runs-on: ubuntu-latest + steps: + - name: Check version format vMAJOR.MINOR.PATCH(-SUFFIX) + run: | + if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then + echo "Invalid version format. Expected vMAJOR.MINOR.PATCH(-SUFFIX)?, got ${GITHUB_REF_NAME}" + exit 1 + fi + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install the project + uses: dronetag/actions/release-python@main + with: + pypi_name: dronetag + pypi_host: ${{ secrets.PRIV_PIP_HOST }} + pypi_user: ${{ secrets.PRIV_PIP_USER }} + pypi_pass: ${{ secrets.PRIV_PIP_PASSWORD }} + version: "${GITHUB_REF_NAME#v}" + + - name: Commit version on release branch + run: | + if [[ $(git rev-parse heads/main) = $(git rev-parse ${GITHUB_REF}) ]]; then + echo "We are at the top of main branch so we can commit the version bump" + git checkout main + git add pyproject.toml + git commit -m "Release ${GITHUB_REF_NAME#v} [skip ci]" + git push + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..299171c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +name: "RELEASE" + +on: + workflow_dispatch: + +jobs: + release: + name: Create release tag + runs-on: ubuntu-latest + steps: + - name: Checkout repository (full-depth) + uses: actions/checkout@v4 + with: { fetch-depth: 0 } # Required to determine version + + - name: Get next release version + uses: dronetag/actions/get-next-version@main + id: get-next-version + + - name: Create the tag + run: | + ls -al # just for testing the changelog artifact + git config --local user.email "" && git config --local user.name "GitHub Action" + git tag -a "v${{ steps.get-next-version.outputs.version }}" -m "${{ steps.get-next-version.outputs.changelog }}" + git push origin "v${{ steps.get-next-version.outputs.version }}" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d136d10..d4cd784 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,29 +10,50 @@ repos: entry: ruff language: system types: [python] + stages: [pre-commit] - id: ruff-format name: ruff format entry: ruff format --diff language: system types: [python] + stages: [pre-commit] - id: mypy name: mypy - entry: mypy --exclude tests --ignore-missing-imports --follow-imports=skip --pretty + entry: mypy --exclude tests --pretty language: system types: [python] + stages: [pre-commit] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - id: trailing-whitespace + stages: [pre-commit] - id: check-docstring-first + stages: [pre-commit] - id: check-added-large-files + stages: [pre-commit] + - id: detect-aws-credentials + stages: [pre-commit] + - id: detect-private-key + stages: [pre-commit] + - id: check-json + stages: [pre-commit] + - id: check-toml + stages: [pre-commit] - id: check-yaml + stages: [pre-commit] - id: debug-statements + stages: [pre-commit] - id: check-merge-conflict + stages: [pre-commit] + - id: mixed-line-ending + args: [--fix=lf] + stages: [pre-commit] - id: end-of-file-fixer + stages: [pre-commit] - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook rev: v9.11.0 diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..a1e4d4a --- /dev/null +++ b/.releaserc @@ -0,0 +1,18 @@ +{ + "branches": [ + { "name": "main" }, + { "name": "[a-z]+/([a-zA-Z0-9\\-]+)", "prerelease": "${name.replace(/^.*\\//g, '')}"} + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "releaseRules": [ + { "type": "refactor", "release": "patch"}, + { "type": "perf", "release": "patch" } + ] + } + ], + "@semantic-release/release-notes-generator" + ] +}