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

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

permissions:
contents: read
id-token: write

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

jobs:
testpypi:
name: Build and publish quantem.widget
runs-on: ubuntu-latest
environment: testpypi
defaults:
run:
shell: bash -el {0}

steps:
- name: Check out repository
uses: actions/checkout@v6

- name: Set up Conda
uses: conda-incubator/setup-miniconda@v4
with:
activate-environment: quantem-widget-release
environment-file: widget/environment.yml
auto-update-conda: true
channel-priority: strict
conda-remove-defaults: true

- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: "22.x"
check-latest: true
cache: npm
cache-dependency-path: widget/package-lock.json

- name: Resolve widget version from tag
id: version
run: |
python - <<'PY'
import os
import re

tag = os.environ["GITHUB_REF_NAME"]
match = re.fullmatch(r"widget-v(?P<version>\d+\.\d+\.\d+(?:rc\d+|\.post\d+)?)", tag)
if match is None:
raise SystemExit(
f"Expected tag widget-vX.Y.Z, widget-vX.Y.ZrcN, or widget-vX.Y.Z.postN; got {tag!r}"
)

with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
print(f"version={match.group('version')}", file=output)
PY

- name: Build frontend assets
working-directory: widget
run: |
npm ci
npm run typecheck
npm run build
test -s src/quantem/widget/static/show2d.js
test -s src/quantem/widget/static/show4dstem.js

- name: Stamp widget package version
env:
WIDGET_VERSION: ${{ steps.version.outputs.version }}
run: |
python - <<'PY'
import os
import pathlib
import re

path = pathlib.Path("widget/pyproject.toml")
text = path.read_text(encoding="utf-8")
version = os.environ["WIDGET_VERSION"]
updated, count = re.subn(
r'(?m)^version = "[^"]+"$',
f'version = "{version}"',
text,
count=1,
)
if count != 1:
raise SystemExit("Expected exactly one project.version field")
path.write_text(updated, encoding="utf-8")
PY

- name: Build widget distributions
run: python -m build widget --no-isolation --outdir dist/widget

- name: Check widget distributions
run: python -m twine check dist/widget/*

- name: Publish widget to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/widget/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,5 @@ widget/scripts/
widget/tests/integration/
widget/tests/snapshots/


widget/PERFORMANCE.md
9 changes: 9 additions & 0 deletions widget/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: quantem-widget-release
channels:
- conda-forge
dependencies:
- python=3.11
- hatchling
- pip
- python-build
- twine
Loading
Loading