Skip to content

Commit

Permalink
pyoproject.toml, trusted deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed Oct 29, 2023
1 parent 203db90 commit ec468a2
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 79 deletions.
39 changes: 26 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
name: build

on:
push:
branches: [ master ]
branches:
- main
- 'dev/**'
pull_request:
branches: [ master ]
branches: [ main ]
release:
types:
- published

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -15,7 +22,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.10"

- name: Install dependencies
run: |
Expand All @@ -30,32 +37,41 @@ jobs:
pylint --rcfile test/pylint.rc gitmetheurl
#-------------------------------------------------------------------------------
build_sdist:
build:
needs:
- lint
name: Build source distribution
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: 3.8
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install -U build
- name: Build sdist
run: python setup.py sdist
- name: Build
run: python -m build

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
path: |
dist/*.tar.gz
dist/*.whl
#-------------------------------------------------------------------------------
deploy:
needs:
- build_sdist
- build

runs-on: ubuntu-latest
environment: release
permissions:
id-token: write

# Only publish when a GitHub Release is created.
if: github.event_name == 'release'
Expand All @@ -66,6 +82,3 @@ jobs:
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/git-me-the-url.svg)](https://pypi.org/project/git-me-the-url)
[![build](https://github.com/amykyta3/git-me-the-url/actions/workflows/build.yml/badge.svg)](https://github.com/amykyta3/git-me-the-url/actions?query=workflow%3Abuild+branch%3Amaster)
[![build](https://github.com/amykyta3/git-me-the-url/actions/workflows/build.yml/badge.svg)](https://github.com/amykyta3/git-me-the-url/actions?query=workflow%3Abuild+branch%3Amain)

# Git me the URL!

Expand Down
4 changes: 2 additions & 2 deletions gitmetheurl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_source_url(self, path: str, line: "Optional[Union[int, Tuple[int, int]]]
return translator.get_source_url(remote, info)


@functools.lru_cache(maxsize=None)
@functools.lru_cache()
def _get_target_info(self, path:str, exact_commit: bool = False) -> 'Tuple[str, dict]':
"""
Collects relevant Git information about the target path.
Expand Down Expand Up @@ -111,7 +111,7 @@ def _get_target_info(self, path:str, exact_commit: bool = False) -> 'Tuple[str,

return remote, info

@functools.lru_cache(maxsize=None)
@functools.lru_cache()
def _lookup_translator(self, remote:str) -> 'Optional[Type[TranslatorSpec]]':
for t in self.translators:
if t.is_match(remote):
Expand Down
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "git-me-the-url"
dynamic = ["version"]
requires-python = ">=3.5"
dependencies = [
"gitpython",
]

authors = [
{name="Alex Mykyta"},
]
description = "Generate sharable links to your Git source"
readme = "README.md"
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
"Topic :: Software Development :: Version Control :: Git",
]

[project.urls]
Source = "https://github.com/amykyta3/git-me-the-url"
Tracker = "https://github.com/amykyta3/git-me-the-url/issues"
Changelog = "https://github.com/amykyta3/git-me-the-url/releases"

[tool.setuptools.dynamic]
version = {attr = "gitmetheurl.__about__.__version__"}

[project.scripts]
gitmetheurl = "gitmetheurl.cmd:main"
54 changes: 0 additions & 54 deletions setup.py

This file was deleted.

14 changes: 5 additions & 9 deletions test/pylint.rc
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,11 @@ disable=
protected-access,
duplicate-code,
cyclic-import,
eval-used,
wrong-import-position,

# Can't do until py35 support is dropped
consider-using-f-string,

# User ignored
wrong-import-position,
eval-used,
import-outside-toplevel,
method-cache-max-size-none
consider-using-f-string

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -575,5 +571,5 @@ preferred-modules=

# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception

0 comments on commit ec468a2

Please sign in to comment.