diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 6fb590e..81ed0c6 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,11 +1,11 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python package +name: Run tests on: push: - branches: [ main ] + branches: [ '*' ] pull_request: branches: [ main ] diff --git a/.github/workflows/python-publish-live.yml b/.github/workflows/python-publish-live.yml new file mode 100644 index 0000000..a4f8876 --- /dev/null +++ b/.github/workflows/python-publish-live.yml @@ -0,0 +1,31 @@ +# This workflow will upload the package to Live Registry of PyPI when a release is created. +# The package will be published here: https://pypi.org/project/codeguru-profiler-agent/ +# For more information see: https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python#publishing-to-package-registries + +name: Publish to Live PyPI + +on: + release: + types: [released] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: '__token__' + TWINE_PASSWORD: ${{ secrets.PYPI_LIVE_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine check dist/* + twine upload --verbose dist/* diff --git a/.github/workflows/python-publish-test.yml b/.github/workflows/python-publish-test.yml new file mode 100644 index 0000000..4623b7b --- /dev/null +++ b/.github/workflows/python-publish-test.yml @@ -0,0 +1,32 @@ +# This workflow will upload the package to Test Registry of PyPI when a pre-release is created. +# The package will be published here: https://test.pypi.org/project/codeguru-profiler-agent/ +# For more information see: https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python#publishing-to-package-registries + +name: Publish to Test PyPI + +on: + release: + types: [prereleased] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: '__token__' + TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} + TWINE_REPOSITORY_URL: 'https://test.pypi.org/legacy/' + run: | + python setup.py sdist bdist_wheel + twine check dist/* + twine upload --verbose dist/* diff --git a/.gitignore b/.gitignore index b15db01..9ff3fcb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ __pycache__/ pytest-report.html +*.egg-info +dist/* diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..cd37aa9 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,32 @@ + +# Release + +## How to release to PyPI + +#### Create PR with the new agent version + +- Create a pull request that updates the agent's version number in the source code [here](https://github.com/aws/amazon-codeguru-profiler-python-agent/blob/main/codeguru_profiler_agent/agent_metadata/agent_metadata.py#L12). You can use directly the editor to edit the file and create the PR. + +- Get approval from the [amazon-codeguru-profiler team](https://github.com/orgs/aws/teams/amazon-codeguru-profiler). + +- Wait until the [``Run tests`` workflow](https://github.com/aws/amazon-codeguru-profiler-python-agent/actions) passes successfully. + +#### Publish package to Test PyPI + +- Create a [new pre-release](https://github.com/aws/amazon-codeguru-profiler-python-agent/releases/new) with the agent version and details about what is changed, in the format of a changelog as [in previous releases](https://github.com/aws/amazon-codeguru-profiler-python-agent/releases). Make sure you check the box with "pre-release". + +- This will trigger a release to the Test Registry of PyPI, and you can track it in the [Actions tab](https://github.com/aws/amazon-codeguru-profiler-python-agent/actions). + +- You can use the agent now from the PyPI **Test** registry as [codeguru-profiler-agent](https://test.pypi.org/project/codeguru-profiler-agent/). + +#### Publish package to Live PyPI + +- If you want to release to the Live registry of PyPI to be used by customers, go to the [Releases tab]([here](https://test.pypi.org/project/codeguru-profiler-agent/) and edit your pre-releases as prod release. + +- This will trigger publishing the package to the Live Registry of PyPI, and you can track it in the [Actions tab](https://github.com/aws/amazon-codeguru-profiler-python-agent/actions). + +- You can use the agent now from the PyPI **Live** registry as [codeguru-profiler-agent](https://pypi.org/project/codeguru-profiler-agent/). + +## How to release the Lambda Layer. + +Check internal instructions. diff --git a/README.md b/README.md index f567230..d1453f7 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ Check the GitHub repository at [aws/amazon-codeguru-profiler-python-agent](https See [CONTRIBUTING](CONTRIBUTING.md) for details. -## How to release to PyPI +## How to release -Use the `setup.py` script to create the archive. +See [DEVELOPMENT](DEVELOPMENT.md) for more information. ## Security diff --git a/codeguru_profiler_agent/agent_metadata/agent_metadata.py b/codeguru_profiler_agent/agent_metadata/agent_metadata.py index 2264c4f..df35d86 100644 --- a/codeguru_profiler_agent/agent_metadata/agent_metadata.py +++ b/codeguru_profiler_agent/agent_metadata/agent_metadata.py @@ -9,7 +9,7 @@ # NOTE: Please do not alter the value for the following constants without the full knowledge of the use of them. # These constants are used in several scripts, including setup.py. __agent_name__ = "CodeGuruProfiler-python" -__agent_version__ = "1.0.1" +__agent_version__ = "1.0.2-dev.1" def look_up_fleet_info( diff --git a/setup.py b/setup.py index 863b660..4d128f4 100755 --- a/setup.py +++ b/setup.py @@ -28,7 +28,8 @@ def find_version(*file_paths): packages=find_packages(exclude=("test",)), description="The Python agent to be used for Amazon CodeGuru Profiler", - long_description="https://docs.aws.amazon.com/codeguru/latest/profiler-ug/what-is-codeguru-profiler.html", + long_description=read("README.md"), + long_description_content_type="text/markdown", author="Amazon Web Services", url="https://github.com/aws/amazon-codeguru-profiler-python-agent", download_url="https://github.com/aws/amazon-codeguru-profiler-python-agent",