diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..fc839443 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + - name: Build wheels + run: ./scripts/build.sh + - name: Install twine + run: | + pip install twine + # The step below publishes to testpypi in order to catch any issues + # with the package configuration that would cause a failure to upload + # to pypi. One example of such a failure is if a classifier is + # rejected by pypi (e.g "3 - Beta"). This would cause a failure during the + # middle of the package upload causing the action to fail, and certain packages + # might have already been updated, this would be bad. + - name: Publish to TestPyPI + env: + TWINE_USERNAME: '__token__' + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_AUTOMATIC_RELEASE_TOKEN }} + run: | + twine upload --repository testpypi --skip-existing --verbose dist/* + - name: Publish to PyPI + env: + TWINE_USERNAME: '__token__' + TWINE_PASSWORD: ${{ secrets.PYPI_AUTOMATIC_RELEASE_TOKEN }} + run: | + twine upload --skip-existing --verbose dist/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 80917a66..3de9454c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- Added publishing action + ([#193](https://github.com/microsoft/ApplicationInsights-Python/pull/193)) + ## [1.0.0b6](https://github.com/microsoft/ApplicationInsights-Python/releases/tag/v1.0.0b6) - 2022-08-30 - Drop support for Python 3.6 diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 00000000..b08ac715 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# This script builds wheels for the API, SDK, and extension packages in the +# dist/ dir, to be uploaded to PyPI. + +set -ev + +# Get the latest versions of packaging tools +python -m pip install --upgrade pip build setuptools wheel + +BASEDIR=$(dirname $(readlink -f $(dirname $0))) +DISTDIR=dist + +( + cd $BASEDIR + mkdir -p $DISTDIR + rm -rf $DISTDIR/* + + for d in azure-monitor-opentelemetry-distro; do + ( + echo "building $d" + cd "$d" + # Package distribution in dist folder + python setup.py sdist --dist-dir "$BASEDIR/dist/" clean --all + ) + done + # Build a wheel for each source distribution + ( + cd $DISTDIR + for x in *.tar.gz ; do + pip wheel --no-deps $x + done + ) +)