diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2e8690d..b90d369 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Python application on: @@ -13,27 +10,19 @@ permissions: contents: read jobs: - build: - + test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v6 with: - python-version: "3.10" + enable-cache: true + - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + run: uv sync + - name: Test with pytest - run: | - pytest + run: uv run pytest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2f1cbf8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release + +on: + push: + branches: [ master ] + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + + - name: Read version from pyproject.toml + id: version + run: | + VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Check if tag already exists + id: tag_check + run: | + if git rev-parse "refs/tags/${{ steps.version.outputs.version }}" >/dev/null 2>&1; then + echo "exists=true" >> "$GITHUB_OUTPUT" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create tag and release + if: steps.tag_check.outputs.exists == 'false' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION="${{ steps.version.outputs.version }}" + git tag "$VERSION" + git push origin "$VERSION" + gh release create "$VERSION" \ + --title "Release $VERSION" \ + --generate-notes diff --git a/.gitignore b/.gitignore index 46e2ab6..0744ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,36 +13,17 @@ __pycache__/ *.so .Python build/ -develop-eggs/ dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ *.egg-info/ -.installed.cfg -*.egg -MANIFEST -*.manifest -*.spec -pip-log.txt -pip-delete-this-directory.txt -htmlcov/ -.tox/ -.nox/ +.pytest_cache/ .coverage .coverage.* -.cache -nosetests.xml coverage.xml -*.cover -*.py,cover +htmlcov/ +.tox/ +.nox/ .hypothesis/ -.pytest_cache/ -cover/ \ No newline at end of file + +# uv +.venv/ +uv.lock diff --git a/README.md b/README.md index fe264fd..9221d93 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,17 @@ I have not heard of any account bans since the tool was written, but rate limiti ### Pre-requisites -Install the Python dependencies with `pip3 install -r ./requirements.txt`. +Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then from the repo root run: + +``` +uv sync +``` + +This creates a virtual environment and installs all dependencies automatically. Run the tool with: + +``` +uv run python linkedin2username.py -c targetco +``` You'll also need Chrome, Chromium, or Firefox installed in typical paths that can be discovered by Selenium. A web browser will be spawned temporarily to handle the login. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c94e621 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[project] +name = "linkedin2username" +version = "0.29" +requires-python = ">=3.10" +dependencies = [ + "requests>=2.34.2", + "selenium>=4.44.0", + "urllib3>=2.7.0", +] + +[dependency-groups] +dev = [ + "pytest", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a2ca48c..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests -selenium