Skip to content

Commit

Permalink
Add CI & release infra.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Dec 23, 2024
1 parent a298d19 commit c3bf38e
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: jsirois

56 changes: 56 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI
on:
push:
branches:
- main
paths:
- 'python/**'
- '!python/**.md'
pull_request:
paths:
- 'python/**'
- '!python/**.md'
defaults:
run:
shell: bash
concurrency:
group: CI-${{ github.ref }}
# Queue on all branches and tags, but only cancel overlapping PR burns.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}
jobs:
org-check:
name: Check GitHub Organization
if: github.repository_owner == 'a-scie'
runs-on: ubuntu-24.04
steps:
- name: Noop
run: "true"
checks:
name: ${{ matrix.name }}
needs: org-check
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: "Linux Python 3.9"
os: "ubuntu-24.04"
python-version: "3.9"
- name: "Linux Python 3.13"
os: "ubuntu-24.04"
python-version: "3.13"
- name: "Mac Python 3.13"
os: "macos-14"
python-version: "3.13"
- name: "Windows Python 3.13"
os: "windows-2022"
python-version: "3.13"
steps:
- name: Checkout science-installers
uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run CI checks
run: uv --directory python run dev-cmd ci -- -vvs

66 changes: 66 additions & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release
on:
push:
tags:
- python-v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:
inputs:
tag:
description: The tag to manually run a deploy for.
required: true
defaults:
run:
shell: bash
jobs:
org-check:
name: Check GitHub Organization
if: ${{ github.repository_owner == 'a-scie' }}
runs-on: ubuntu-24.04
steps:
- name: Noop
run: "true"
determine-tag:
name: Determine the release tag to operate against.
needs: org-check
runs-on: ubuntu-24.04
outputs:
release-tag: ${{ steps.determine-tag.outputs.release-tag }}
release-version: ${{ steps.determine-tag.outputs.release-version }}
steps:
- name: Determine Tag
id: determine-tag
run: |
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
RELEASE_TAG=${{ github.event.inputs.tag }}
else
RELEASE_TAG=${GITHUB_REF#refs/tags/}
fi
if [[ "${RELEASE_TAG}" =~ ^python-v[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo "release-tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT
echo "release-version=${RELEASE_TAG#python-v}" >> $GITHUB_OUTPUT
else
echo "::error::Release tag '${RELEASE_TAG}' must match 'python-v\d+.\d+.\d+'."
exit 1
fi
pypi:
name: Publish sdist and wheel to PyPI
needs: determine-tag
runs-on: ubuntu-24.04
environment: Release
permissions:
id-token: write
steps:
- name: Checkout science-installers ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
- name: Build sdist and wheel
run: uv --directory python build
- name: Publish insta-science ${{ needs.determine-tag.outputs.release-version }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist
print-hash: true
verbose: true
1 change: 1 addition & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build artifacts dirs.
/*.egg-info/
/build/

# Python bytecode.
__pycache__/
Expand Down
6 changes: 6 additions & 0 deletions python/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# insta-science

## 0.1.0.dev0

Prime release channel (will be deleted).

33 changes: 33 additions & 0 deletions python/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Release Process

## Preparation

### Version Bump and Changelog

1. Bump the version in [`insta_science/__init__.py`](insta_science/__init__.py).
2. Run `uv run dev-cmd` as a sanity check on the state of the project.
3. Update [`CHANGES.md`](CHANGES.md) with any changes that are likely to be useful to consumers.
4. Open a PR with these changes and land it on https://github.com/a-scie/science-installers main.

## Release

### Push Release Tag

Sync a local branch with https://github.com/a-scie/science-installers main and confirm it has the
version bump and changelog update as the tip commit:
```
$ git log --stat -1 HEAD | grep -E "CHANGES|__init__"
python/CHANGES.md | 5 +
python/insta_science/__init__.py | 4 +```
```

Tag the release as `python-v<version>` and push the tag to
https://github.com/a-scie/science-installers main:
```
$ git tag --sign -am 'Release 0.1.0' python-v0.1.0
$ git push --tags https://github.com/a-scie/science-installers HEAD:main
```

The release is automated and will create a PyPI release at
[https://pypi.org/project/insta-science/&lt;version&gt;/](
https://pypi.org/project/insta-science/#history).
2 changes: 1 addition & 1 deletion python/insta_science/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 Science project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

__version__ = "0.1.0"
__version__ = "0.1.0.dev0"
38 changes: 32 additions & 6 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ backend = "setuptools.build_meta"

[project]
name = "insta-science"
authors = [
{name = "John Sirois", email = "john.sirois@gmail.com"},
]
description = "A tool to help with installing and using science in Python projects."
readme = "README.md"
requires-python = ">=3.9"
license = {file = "LICENSE"}
dependencies = [
"ansicolors",
"appdirs",
Expand All @@ -21,8 +15,40 @@ dependencies = [
"tqdm",
"typing-extensions",
]

authors = [
{name = "John Sirois", email = "john.sirois@gmail.com"},
]
description = "A tool to help with installing and using `science` in Python projects."
readme = "README.md"
license = {file = "LICENSE"}
keywords = ["automation", "command", "runner", "testing"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Build Tools",
"Topic :: Utilities",
]

dynamic = ["version"]

[project.urls]
Repository = "https://github.com/a-scie/science-installers/tree/main/python"
"Bug Tracker" = "https://github.com/a-scie/science-installers/issues"
Changelog = "https://github.com/a-scie/science-installers/blob/main/python/CHANGES.md"

[project.scripts]
insta-science = "insta_science.shim:science"
insta-science-util = "insta_science.util:main"
Expand Down
2 changes: 1 addition & 1 deletion python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c3bf38e

Please sign in to comment.