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
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Checks that gate a pull request and run again on main. The Release workflow reuses this file
# (workflow_call) so nothing ships on a red tree.
name: CI

on:
pull_request:
push:
branches: [main]
workflow_call:

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"

jobs:
lint:
name: lint, format, types
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: astral-sh/[email protected]
with:
python-version: "3.10"
enable-cache: true
- run: uv sync --frozen
- name: ruff lint
run: uv run --frozen ruff check .
- name: ruff format
run: uv run --frozen ruff format --check .
- name: mypy
run: uv run --frozen mypy src

test:
name: python ${{ matrix.python }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v7
- uses: astral-sh/[email protected]
with:
python-version: ${{ matrix.python }}
enable-cache: true
- run: uv sync --frozen
- name: pytest
run: uv run --frozen pytest -q

package:
name: package checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: astral-sh/[email protected]
- name: build wheel and sdist
run: uv build --out-dir dist
- name: check metadata
run: uvx twine check --strict dist/*
136 changes: 136 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Release: when a push to main touches the package and the version in pyproject.toml has no git
# tag yet, run CI, build the wheel and sdist, publish to PyPI, then create the tag `vX.Y.Z` and a
# GitHub release. To release, bump `version` in pyproject.toml (`uv version --bump patch|minor|major`
# also refreshes uv.lock) in a normal PR and merge it. Pushes that do not change the version find
# the tag already present and skip.
#
# One-time setup: on PyPI, add a trusted publisher for project `xrayatlas` with owner
# `WSU-Carbon-Lab`, repository `atlas-python`, workflow `release.yml`, environment `pypi`; and
# create the `pypi` environment in this repository's settings. No API token is stored.
name: Release

on:
push:
branches: [main]
paths:
- pyproject.toml
- uv.lock
- src/**
- .github/workflows/release.yml
workflow_dispatch:
inputs:
dry_run:
description: Build everything but do not publish or tag
type: boolean
default: false

permissions:
contents: read

concurrency:
group: release
cancel-in-progress: false

jobs:
check:
name: decide whether to release
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
release: ${{ steps.v.outputs.release }}
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v7
- uses: astral-sh/[email protected]
- id: v
run: |
version="$(uv version --short)"
if git ls-remote --exit-code --tags origin "refs/tags/v$version" >/dev/null 2>&1; then
echo "Tag v$version already exists: nothing to release."
release=false
else
echo "New version v$version: releasing."
release=true
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "release=$release" >> "$GITHUB_OUTPUT"

ci:
name: tests
needs: check
if: needs.check.outputs.release == 'true' || inputs.dry_run
uses: ./.github/workflows/ci.yml

build:
name: build wheel and sdist
needs: [check, ci]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: astral-sh/[email protected]
- name: build
run: uv build --out-dir dist
- name: assert artifact names match the release version
env:
VERSION: ${{ needs.check.outputs.version }}
run: |
test -f "dist/xrayatlas-$VERSION-py3-none-any.whl"
test -f "dist/xrayatlas-$VERSION.tar.gz"
- name: check metadata
run: uvx twine check --strict dist/*
- name: smoke import from the built wheel
run: |
uv venv --python 3.10 /tmp/smoke
uv pip install --python /tmp/smoke/bin/python dist/*.whl
/tmp/smoke/bin/python -c "import xrayatlas, importlib.metadata as m; print('ok', m.version('xrayatlas'))"
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/*
if-no-files-found: error

publish-pypi:
name: publish to PyPI
needs: [check, build]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/p/xrayatlas
permissions:
id-token: write # PyPI trusted publishing (OIDC); no API token needed
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
skip-existing: true

github-release:
name: tag and GitHub release
needs: [check, publish-pypi]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: create tag and release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.check.outputs.version }}
run: |
gh release create "v$VERSION" dist/* \
--target "$GITHUB_SHA" \
--title "v$VERSION" \
--generate-notes
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2026, WSU Carbon Lab

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading
Loading