Skip to content

Upload unique dev packages to test.pypi.org #114

Upload unique dev packages to test.pypi.org

Upload unique dev packages to test.pypi.org #114

Workflow file for this run

---
name: Package Build & Upload
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 }}
cancel-in-progress: true
jobs:
# Verify the package builds fine
build-package:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: hynek/[email protected]
id: build-pkg
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: x # any version
check-latest: true
- name: Test installing wheel
run: |
pip install ${{ steps.build-pkg.outputs.dist }}/*.whl
pip uninstall --yes tm_devices
- name: Test installing tarball
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