Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish to PyPI

on:
push:
tags:
- "v*" # Triggers when a new GitHub Tag is published eg: v1.2.3
release:
types: [published] # Triggers when a new GitHub Release is published

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache virtualenv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-3.9-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }}

- name: Install dependencies
run: make setup-dev

- name: Set version from GitHub tag
run: |
# Extract tag like "v1.2.3" β†’ "1.2.3"
VERSION=${GITHUB_REF#refs/tags/v}
echo "Setting version to $VERSION"
# Update pyproject.toml version field
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml

- name: Build package
run: make build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m pip install --upgrade pip
pip install twine
python -m twine upload --repository pypi dist/* --verbose
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<a href="https://pypi.org/project/sygra/">
<img src="https://img.shields.io/pypi/v/sygra.svg?logo=pypi&color=orange"/></a>
<a href="https://github.com/ServiceNow/SyGra/actions/workflows/ci.yaml">
<img alt="CI" src="https://github.com/ServiceNow/SyGra/actions/workflows/ci.yaml/badge.svg"/></a>
<a href="https://github.com/ServiceNow/SyGra/actions/workflows/ci.yml">
<img alt="CI" src="https://github.com/ServiceNow/SyGra/actions/workflows/ci.yml/badge.svg"/></a>
<a href="https://github.com/ServiceNow/SyGra/releases">
<img alt="Releases" src="https://img.shields.io/github/v/release/ServiceNow/SyGra?logo=bookstack&logoColor=white"/></a>
<a href="https://servicenow.github.io/SyGra">
Expand Down