Skip to content

Commit

Permalink
fix!: use pypi on github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-zahedi committed Mar 28, 2024
1 parent 889ba77 commit 521051e
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 111 deletions.
32 changes: 32 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_size = 4
continuation_indent_size = 8
indent_style = space
max_line_length = 120

[*.{html,js,css,scss,json}]
indent_style = space
indent_size = 4

[*.cfg]
indent_size = 4
indent_style = space

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
indent_size = 4

[*.{yml,yaml}]
indent_style = space
indent_size = 2
37 changes: 37 additions & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---

name: Linters

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
pre-commit-linter:
name: pre-commit-linter
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.base_ref }}
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: python -m pip install pre-commit
- name: linter
run: >-
pre-commit run --color always --all-files
-s ${GITHUB_BASE_REF_SHA} -o HEAD
env:
GITHUB_BASE_REF_SHA: ${{ github.event.pull_request.base.sha }}
70 changes: 70 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: Version

on:
push:
branches:
- main
- develop

jobs:
versioning_pipeline:
environment:
name: ${{ github.ref_name }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_output.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Setup package.json
run: |
echo '{"name":"demo", "devDependencies":{"@semantic-release/github":"9.0.4","@semantic-release/exec":"6.0.3","semantic-release":"21.0.7"}}' > package.json
- name: Install semantic-release
run: |
npm install
- name: Run semantic-release
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release
# Extract the version from the new git tag
NEW_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
- name: Set version output
id: set_output
run: echo "::set-output name=version::$NEW_TAG"

pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: versioning_pipeline
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Build package
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Update package version
run: |
VERSION=${{ needs.versioning_pipeline.outputs.version }}
echo "Version: $VERSION"
sed -i "s/__version__ = \"1.0.0\"/__version__ = \"$VERSION\"/g" setup.py
- name: Install build
run: python -m pip install build
- name: Build dist
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
67 changes: 0 additions & 67 deletions .gitlab-ci.yml

This file was deleted.

67 changes: 53 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,60 @@
---

repos:
- repo: https://github.com/pycqa/isort
rev: 5.8.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/ambv/black
rev: stable
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: debug-statements
- id: end-of-file-fixer
exclude_types: [svg, plain-text]
- id: trailing-whitespace
exclude_types: [svg]
- id: check-added-large-files
- id: check-shebang-scripts-are-executable
- id: check-yaml
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/pycqa/flake8
rev: '' # pick a git hash / tag to point to
args: ['--config=pyproject.toml']
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.7.0
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
types: [python]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
language: python
language_version: python3.11
types: [python]
additional_dependencies:
- flake8-black>=0.2.2
language_version: python3

- flake8-black>=0.2.2
- flake8-mutable
- flake8-gl-codeclimate
- flake8-bugbear
- flake8-comprehensions
- flake8-print
- flake8-simplify
- flake8-django
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.16.0
hooks:
- id: django-upgrade
args: [--target-version, "5.0"]
types: [python]
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
hooks:
- id: yamllint
22 changes: 22 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

{
"plugins": [
"@semantic-release/commit-analyzer",
[
"@semantic-release/exec",
{
"verifyReleaseCmd": "echo ${nextRelease.version} > VERSION.txt",
"prepareCmd": "echo ${nextRelease.version} > VERSION.txt"
}
],
"@semantic-release/github"
],
"branches": [
"main",
{
"name": "develop",
"prerelease": "alpha"
}
]
}
13 changes: 0 additions & 13 deletions .releaserc.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: default

rules:
line-length:
# TODO: fix it!
max: 500
30 changes: 17 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
[build-system]
requires = ['setuptools>=40.8.0']
build-backend = 'setuptools.build_meta'

[tool.black]
indent = 4
line-length = 110
skip-string-normalization=1
line-length = 119
include = '\.pyi?$'
max_attribute_length = 10
profile = 'django'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| frontend
| .+/migrations
migrations
| __pycache__
| \.git
)/
'''

[tool.isort]
profile = "black"
combine_as_imports = true
include_trailing_comma = true
lines_after_imports = 2
multi_line_output = 3
skip = ["migrations", "__pycache__", ".git", "env", ".env", "venv", ".venv", ".direnv"]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 521051e

Please sign in to comment.