Skip to content

Commit

Permalink
ci: Created a separate workflow for the TestPyPI upload. Also updated…
Browse files Browse the repository at this point in the history
… the readme with a new badge for the new workflow.
  • Loading branch information
nfelt14 committed Oct 5, 2023
1 parent e5294e6 commit a1746d2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 69 deletions.
71 changes: 3 additions & 68 deletions .github/workflows/package-build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -20,6 +15,7 @@ jobs:
build-package:
name: Build package
runs-on: ubuntu-latest
environment: package-build
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -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/[email protected]
with:
changelog: 'false'
commit: 'false'
vcs_release: 'false'
build_metadata: dev.$(git rev-parse --short ${{ github.sha }})
- uses: hynek/[email protected]
- name: Upload package to Test PyPI
uses: pypa/[email protected]
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/[email protected]
- 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
47 changes: 47 additions & 0 deletions .github/workflows/package-testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
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' && github.event_name == 'push'
&& github.ref == 'refs/heads/main'
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/[email protected]
with:
changelog: 'false'
commit: 'false'
vcs_release: 'false'
build_metadata: ${{ env.VERSION }})
- uses: hynek/[email protected]
- name: Upload package to Test PyPI
uses: pypa/[email protected]
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
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit a1746d2

Please sign in to comment.