diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml new file mode 100644 index 0000000..5ce8e63 --- /dev/null +++ b/.github/workflows/python-publish.yaml @@ -0,0 +1,53 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Pypi + +on: + release: + types: [published] + push: + branches: [ "main" ] + tags: [ "v*.*.*" ] + +permissions: + contents: read + +jobs: + deploy: + name: Publish python package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade --upgrade-strategy=eager pip setuptools wheel twine pipenv + python -m pip install -e . --upgrade + python -m pipenv install --dev --python 3.10 + env: + PIPENV_DEFAULT_PYTHON_VERSION: "3.10" + + - name: Build wheels + run: | + python -m pipenv run python setup.py sdist bdist_wheel + + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + verbose: true + skip_existing: true + password: ${{ secrets.PYPI_API_TOKEN }} + packages_dir: dist/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ca0973..105a523 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store - +__pycache__ +*.csv \ No newline at end of file diff --git a/instagram_locations/instagram_locations.py b/instagram_locations/instagram_locations.py index 3029251..7827a68 100644 --- a/instagram_locations/instagram_locations.py +++ b/instagram_locations/instagram_locations.py @@ -31,7 +31,7 @@ def get_instagram_locations(lat, lng, cookie): try: locations = response.json() except json.JSONDecodeError: - print(f"Failed to get location data for {lat_long}") + print(f"Failed to get location data for {lat_long}: please check you have a valid cookie") return [] if not isinstance(locations, dict): @@ -52,6 +52,7 @@ def get_instagram_locations_by_query(query): # in order to return additional results def get_fuzzy_locations(lat, lng, cookie, sigma=2): locs = get_instagram_locations(lat, lng, cookie) + print(locs) loc_ids = {v["external_id"] for v in locs if "external_id" in v} std_lat = pstdev([v["lat"] for v in locs if "lat" in v]) @@ -231,4 +232,7 @@ def main(): ids = map(lambda loc: str(loc["external_id"]), locations) with open(args.dump_ids, "w") as f: f.write("\n".join(ids)) - \ No newline at end of file + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100644 index 0000000..cf1fc39 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,19 @@ + +#!/bin/bash + +set -e + +TAG=$(python -c 'from instagram_locations.instagram_locations.version import __version__; print("v" + __version__)') + +read -p "Creating new release for $TAG. Do you want to continue? [Y/n] " prompt + +if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then + git add -A + git commit -m "Bump version to $TAG for release" || true && git push + echo "Creating new git tag $TAG" + git tag "$TAG" -m "$TAG" + git push --tags +else + echo "Cancelled" + exit 1 +fi \ No newline at end of file diff --git a/setup.py b/setup.py index 7feb055..f63729f 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ setuptools.setup( name="instagram-location-search", version="1.0.0", author="Bellingcat", + author_email="tech@bellingcat.com" packages=["instagram_locations"], description="Finds Instagram location IDs near a specified latitude and longitude.", long_description=long_description,