Skip to content

epic(tmrpc): all passing tests for v0.21 (#243) #202

epic(tmrpc): all passing tests for v0.21 (#243)

epic(tmrpc): all passing tests for v0.21 (#243) #202

Workflow file for this run

name: Publish Python 🐍 distribution 📦 to PyPI
on:
push:
branches: ["master", "release-test"]
jobs:
publish:
# ref: on conditional GHA steps - https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
# When a GitHub push event contains several commits,
# ${{ github.event.commits[0].message }} is the oldest commit
# ${{ github.event.head_commit.message }} is the youngest commit
# bump-patch: 0.0.0 → 0.0.1
# bump-minor: 0.0.* → 0.1.0
# bump-major: 0.*.* → 1.0.0
# bump-prepatch: 0.0.0 → 0.0.1-alpha0
# bump-prerelease = bump-prepatch
# bump-preminor: 0.0.* → 0.1.0-alpha0
# bump-premajor: 0.*.* → 1.0.0-alpha0
if: |
contains(github.event.head_commit.message, 'bump-patch') ||
contains(github.event.head_commit.message, 'bump-minor') ||
contains(github.event.head_commit.message, 'bump-major') ||
contains(github.event.head_commit.message, 'bump-prepatch') ||
contains(github.event.head_commit.message, 'bump-preminor') ||
contains(github.event.head_commit.message, 'bump-premajor') ||
contains(github.event.head_commit.message, 'bump-prelease')
runs-on: ubuntu-20.04
env:
HEAD_COMMIT_MESSAGE: $${{ github.event.head_commit.message }}
steps:
- name: Set the version env var for poetry publish
run: |
echo "head commit msg: $HEAD_COMMIT_MESSAGE"
if grep -q "bump-patch" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=patch" >> "$GITHUB_ENV"
elif grep -q "bump-minor" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=minor" >> "$GITHUB_ENV"
elif grep -q "bump-major" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=major" >> "$GITHUB_ENV"
elif grep -q "bump-prepatch" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=prepatch" >> "$GITHUB_ENV"
elif grep -q "bump-preminor" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=preminor" >> "$GITHUB_ENV"
elif grep -q "bump-premajor" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=premajor" >> "$GITHUB_ENV"
elif grep -q "bump-prerelease" <<< $HEAD_COMMIT_MESSAGE; then
echo "VERSION=prerelease" >> "$GITHUB_ENV"
fi
echo "version bump type from commit msg: $VERSION"
# ----------------------------------------------
# check-out repo and set-up python
# ----------------------------------------------
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Python 3.9
id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.9.13
- name: Run python
run: python --version && python -c "print('hello')"
# ----------------------------------------------
# Try to load a cached poetry binary
# See https://github.com/snok/install-poetry#caching-the-poetry-installation for the source
# ----------------------------------------------
- name: Load cached Poetry installation
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-0 # increment to reset cache
# ----------------------------------------------
# Install & configure poetry
# ----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: latest
# ----------------------------------------------
# Build and Publish
# ----------------------------------------------
- name: Validate the pyproject.toml
run: poetry check
- name: Change the package version
run: poetry version $VERSION
- name: Build the assets
run: poetry build
- name: Publish package
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: yes | poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD