pypi releases

This commit is contained in:
msramalho
2023-02-13 15:11:57 +00:00
parent 574d4768bb
commit 4825543853
5 changed files with 81 additions and 3 deletions

53
.github/workflows/python-publish.yaml vendored Normal file
View File

@@ -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/

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.DS_Store
__pycache__
*.csv

View File

@@ -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))
if __name__ == "__main__":
main()

19
scripts/release.sh Normal file
View File

@@ -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

View File

@@ -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,