Skip to content
Merged
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
99 changes: 99 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Release

on:
push:
tags:
- "v*"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
build:
name: Build dists
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.4"
enable-cache: true

- name: Verify tag matches project version
run: |
VER=$(uv version --short)
TAG=${GITHUB_REF_NAME#v}
test "$VER" = "$TAG" || { echo "Tag $TAG != version $VER"; exit 1; }

- name: Build sdist and wheel with uv
run: uv build --no-sources

- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/PubChemPy
permissions:
id-token: write
contents: read
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

release:
name: Create GitHub Release
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: Create GitHub Release (draft)
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
args=(
"${TAG}" dist/*
--title "PubChemPy ${TAG#v}"
--generate-notes
--draft
)
if gh release view "${TAG}" >/dev/null 2>&1; then
echo "Release ${TAG} already exists; skipping create."
else
gh release create "${args[@]}"
fi
Loading