From 4c0c00bd828c554520e9fcba01cfac75c0d05924 Mon Sep 17 00:00:00 2001 From: Yasuo Saito Date: Mon, 21 Mar 2022 07:27:39 +0000 Subject: [PATCH 1/5] add github actions and update setup.py --- .github/workflows/release.yml | 38 +++++++++++++++++++++++++++++++++++ setup.py | 5 ++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f56bbe4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Upload package to PyPI + +on: + release: + types: + - published + +jobs: + build-n-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.7' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel + + - name: Build + run: | + python setup.py sdist + python setup.py bdist_wheel + + - name: Check + run: | + ls ./dist + + - name: Publish a Python distribution to PyPI + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.py b/setup.py index dc0e256..2677dd3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,6 @@ setuptools.setup( name="fastlabel", - version="0.11.16", author="eisuke-ueta", author_email="eisuke.ueta@fastlabel.ai", description="The official Python SDK for FastLabel API, the Data Platform for AI", @@ -18,4 +17,8 @@ install_requires=install_requires, python_requires=">=3.7", include_package_data=True, + use_scm_version=True, + setup_requires=[ + "setuptools_scm" + ], ) From 89069d8ab7fa7ed4ed14d438f12657b840cea86b Mon Sep 17 00:00:00 2001 From: Yasuo Saito Date: Mon, 21 Mar 2022 08:06:20 +0000 Subject: [PATCH 2/5] update guide --- pypi_update_guide.md | 72 +++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/pypi_update_guide.md b/pypi_update_guide.md index 5b52730..2e02a19 100644 --- a/pypi_update_guide.md +++ b/pypi_update_guide.md @@ -4,50 +4,66 @@ _Creating and deploying a new package version is easy_ ## Prerequisites -1. Ensure you're on the latest master +1. Ensure you have a PyPI account created and are added as a Collaborator -2. Ensure you have a PyPI account created and are added as a Collaborator +2. Store PyPI API Token to GitHub Secrets + If you have already registered GitHub Secret `PYPI_API_TOKEN`, skip this step. -## Deployment Steps: + 1. Get PyPI API Token + 1. Go to [PyPI Account Settings Page](https://pypi.org/manage/account/) + 2. Click `Add API Token` button in API Token section + 3. Enter the following + - Token name: `GitHub Actions Token` + - Scope: `Project: fastlabel` + 4. Click `Add Token` button and get API Token -**Step 0: Critical - Bump Project Version** + 2. Store Token to GitHub Secrets + 1. Go to GitHub `fastlabel-python-sdk` repository + 2. Go to Settings > Secrets > Actions + 3. Click `New repository secret` and enter the following + - Name: `PYPI_API_TOKEN` + - Value: PyPI API Token -In `setup.py`, you need to specify a new project version. +## Deployment Steps -We use [semantic versioning](https://packaging.python.org/guides/distributing-packages-using-setuptools/#semantic-versioning-preferred). If you are adding a meaningful feature, bump the minor version. If you are fixing a bug, bump the incremental version. +**Step 1: Create a new release** -**Step 1: Remove Previous Versions** +1. Click `Releases` label in `Code` tab and go to Releases page -Clear out any previously packaged files in the `dist` folder +2. Click `Draft a new release` button -**Step 2: Create a Source Distribution** +3. Enter the following + - Tag + - Click `Choose a tag` select box + - input [version](#version) (ex: 1.12.0) * + - Click `Create new tag: x.x.x` -``` -python3 setup.py sdist -``` + - Target: main -**Step 3: Create `wheel`** + - Release title: `Release x.x.x` (ex: `Release 1.12.0`) -You should also create a wheel for your project. A wheel is a built package that can be installed without needing to go through the “build” process. Installing wheels is substantially faster for the end user than installing from a source distribution + - (Optional) fill in the description -``` -python3 setup.py bdist_wheel -``` +4. Click `Publish release` button -**Step 4: Install Twine** +**Step 2: (Automatically) Execute GitHub Actions Workflow** -Twine is what is used to manage PyPI pacakges +After creating a release, GitHub Actions Workflow will be triggered automatically. +This workflow builds the SDK distribution and uploads it to PyPI. -``` -pip install twine -``` +If the workflow fails, follow these steps: +1. Fix the cause of the error +2. Remove release created in Step 1 +3. Remove tag created in Step 1 +4. Repeat from Step 1 -**Step 5: Upload distribution to PyPI** +**Step 3: Check out the PyPI page to ensure all looks good** -``` -python3 -m twine upload dist/* -``` +[https://pypi.org/project/fastlabel/](https://pypi.org/project/fastlabel/) -**Step 6: Check out the PyPI page to ensure all looks good** -[https://pypi.org/project/fastlabel/](https://pypi.org/project/fastlabel/) +--- +### Version +We use [semantic versioning](https://packaging.python.org/guides/distributing-packages-using-setuptools/#semantic-versioning-preferred). +If you are adding a meaningful feature, bump the minor version. +If you are fixing a bug, bump the incremental version. From aa8c43b1cfa37b8ee4047d87ac50845cdb6a8c33 Mon Sep 17 00:00:00 2001 From: Yasuo Saito Date: Mon, 21 Mar 2022 08:07:19 +0000 Subject: [PATCH 3/5] update --- pypi_update_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypi_update_guide.md b/pypi_update_guide.md index 2e02a19..68f25da 100644 --- a/pypi_update_guide.md +++ b/pypi_update_guide.md @@ -7,7 +7,7 @@ _Creating and deploying a new package version is easy_ 1. Ensure you have a PyPI account created and are added as a Collaborator 2. Store PyPI API Token to GitHub Secrets - If you have already registered GitHub Secret `PYPI_API_TOKEN`, skip this step. + If you have already created GitHub Secret `PYPI_API_TOKEN`, skip this step. 1. Get PyPI API Token 1. Go to [PyPI Account Settings Page](https://pypi.org/manage/account/) From f773d06901eca1525303f2ed5322fd2e85e52477 Mon Sep 17 00:00:00 2001 From: Yasuo Saito Date: Mon, 21 Mar 2022 08:08:22 +0000 Subject: [PATCH 4/5] update --- pypi_update_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypi_update_guide.md b/pypi_update_guide.md index 68f25da..c0a291a 100644 --- a/pypi_update_guide.md +++ b/pypi_update_guide.md @@ -35,7 +35,7 @@ _Creating and deploying a new package version is easy_ 3. Enter the following - Tag - Click `Choose a tag` select box - - input [version](#version) (ex: 1.12.0) * + - input [version](#version) (ex: 1.12.0) - Click `Create new tag: x.x.x` - Target: main From 9f44db9b947a7aeaa62351b78ce0d1c942b06361 Mon Sep 17 00:00:00 2001 From: Yasuo Saito Date: Mon, 21 Mar 2022 08:08:55 +0000 Subject: [PATCH 5/5] update --- pypi_update_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypi_update_guide.md b/pypi_update_guide.md index c0a291a..1a65a00 100644 --- a/pypi_update_guide.md +++ b/pypi_update_guide.md @@ -35,7 +35,7 @@ _Creating and deploying a new package version is easy_ 3. Enter the following - Tag - Click `Choose a tag` select box - - input [version](#version) (ex: 1.12.0) + - input [version](#version) (ex: `1.12.0`) - Click `Create new tag: x.x.x` - Target: main