diff --git a/.github/workflows/package-build.yml b/.github/workflows/package-build.yml index 961c0c70..fdbd1996 100644 --- a/.github/workflows/package-build.yml +++ b/.github/workflows/package-build.yml @@ -1,16 +1,11 @@ --- -name: Package Build & Upload +name: Package Build on: push: branches: [main] tags: ['*'] pull_request: branches: [main] - release: - types: [published] -permissions: - contents: write - id-token: write # Cancel running jobs for the same workflow and branch. concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -20,6 +15,7 @@ jobs: build-package: name: Build package runs-on: ubuntu-latest + environment: package-build steps: - uses: actions/checkout@v3 with: @@ -36,67 +32,6 @@ jobs: pip install ${{ steps.build-pkg.outputs.dist }}/*.whl pip uninstall --yes tm_devices - name: Test installing tarball - run: | + run: |- pip install ${{ steps.build-pkg.outputs.dist }}/*.tar.gz pip uninstall --yes tm_devices - - # Upload to Test PyPI on every push to main - test-pypi: - name: Publish package to test.pypi.org - if: github.repository == 'tektronix/tm_devices' && github.event_name == 'push' - && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Create unique dev package version - uses: python-semantic-release/python-semantic-release@v8.0.0 - with: - changelog: 'false' - commit: 'false' - vcs_release: 'false' - build_metadata: dev.$(git rev-parse --short ${{ github.sha }}) - - uses: hynek/build-and-inspect-python-package@v1.5 - - name: Upload package to Test PyPI - uses: pypa/gh-action-pypi-publish@v1.8.8 - with: - repository-url: https://test.pypi.org/legacy/ - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: x # any version - check-latest: true - - name: Test installing from test.pypi.org - run: pip install --index-url=https://test.pypi.org/simple/ --extra-index-url=https://pypi.org/simple - tm_devices - - # Upload to PyPI and create a tag in the repo after a GitHub Release is published - pypi: - name: Publish released package to pypi.org and create new tag in repo - if: github.repository == 'tektronix/tm_devices' && github.event_name == 'release' - && github.event.action == 'published' - runs-on: ubuntu-latest - needs: build-package - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - - name: Download built package - uses: actions/download-artifact@v3 - with: - name: Packages - path: dist - - name: Upload package to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.8 - - name: Create and push tag - run: |- - git tag --annotate v${{ github.event.release.tag_name }} --message="${{ github.event.release.name }}" - git push --tags - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: x # any version - check-latest: true - - name: Test installing from pypi.org - run: pip install tm_devices diff --git a/.github/workflows/package-testpypi.yml b/.github/workflows/package-testpypi.yml new file mode 100644 index 00000000..90a108ac --- /dev/null +++ b/.github/workflows/package-testpypi.yml @@ -0,0 +1,46 @@ +--- +name: Publish package to test.pypi.org +on: + push: + branches: [main] +permissions: + contents: write + id-token: write +concurrency: + group: test-pypi-upload +jobs: + # Upload to Test PyPI on every push to main + test-pypi: + name: Publish package to test.pypi.org + if: github.repository == 'tektronix/tm_devices' + runs-on: ubuntu-latest + environment: package-testpypi + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create dev version metadata + run: | + VERSION=dev.$(git rev-parse --short ${{ github.sha }}) + echo Version: $VERSION + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Create unique dev package version + uses: python-semantic-release/python-semantic-release@v8.0.0 + with: + changelog: 'false' + commit: 'false' + vcs_release: 'false' + build_metadata: ${{ env.VERSION }}) + - uses: hynek/build-and-inspect-python-package@v1.5 + - name: Upload package to Test PyPI + uses: pypa/gh-action-pypi-publish@v1.8.8 + with: + repository-url: https://test.pypi.org/legacy/ + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: x # any version + check-latest: true + - name: Test installing from test.pypi.org + run: pip install --index-url=https://test.pypi.org/simple/ --extra-index-url=https://pypi.org/simple + tm_devices diff --git a/README.rst b/README.rst index ba46f20a..e5929e4d 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ * - Code Quality - |CodeQL status| |CodeFactor grade| |pre-commit status| * - Package - - |PyPI: Package status| |PyPI: Latest release version| |PyPI: Supported Python versions| |License: Apache 2.0| |PyPI: Downloads| |Package build status| + - |PyPI: Package status| |PyPI: Latest release version| |PyPI: Supported Python versions| |License: Apache 2.0| |PyPI: Downloads| |Package build status| |TestPyPI upload status| * - Documentation - |Documentation status| * - Code Style @@ -34,6 +34,9 @@ .. |Package build status| image:: https://github.com/tektronix/tm_devices/actions/workflows/package-build.yml/badge.svg?branch=main :target: https://github.com/tektronix/tm_devices/actions/workflows/package-build.yml +.. |TestPyPI upload status| image:: https://github.com/tektronix/tm_devices/actions/workflows/package-testpypi.yml/badge.svg?branch=main + :target: https://github.com/tektronix/tm_devices/actions/workflows/package-testpypi.yml + .. |Coverage status| image:: https://codecov.io/gh/tektronix/tm_devices/branch/main/graph/badge.svg :target: https://codecov.io/gh/tektronix/tm_devices