-
-
Notifications
You must be signed in to change notification settings - Fork 792
95 lines (88 loc) · 3.94 KB
/
Copy pathrelease_solvers.yml
File metadata and controls
95 lines (88 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Build and publish pybammsolvers wheels + sdist to PyPI.
#
# Monorepo notes:
# - The wheel/sdist build logic lives in the reusable workflow
# `_build_solver_wheels.yml`, shared with PR-time CI (test_on_push.yml). This
# workflow only adds the release trigger, the tag-namespace guard, and the
# PyPI publish step.
# - Releases are discriminated by tag namespace (`pybammsolvers-v*`); the old
# `github.repository == 'pybamm-team/pybammsolvers'` guard no longer works now
# that pybamm and pybammsolvers share a repository.
name: Build solver wheels
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
save_vcpkg_logs:
description: "Upload vcpkg build logs for Windows (useful for debugging CI failures)"
default: false
required: false
type: boolean
jobs:
build:
name: Build wheels + sdist
# On release events, only build for the solver tag namespace. Always build
# on workflow_dispatch (manual testing). A fresh build (no cache) for release.
if: ${{ github.event_name != 'release' || startsWith(github.event.release.tag_name, 'pybammsolvers-v') }}
permissions:
contents: read
uses: ./.github/workflows/_build_solver_wheels.yml
with:
cache_wheels: false
build_sdist: true
save_vcpkg_logs: ${{ github.event_name == 'workflow_dispatch' && inputs.save_vcpkg_logs }}
check_version:
# Guard against tag/version.py desync: the published version comes from
# version.py, not the tag, so fail early instead of shipping the wrong one.
if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'pybammsolvers-v') }}
name: Check tag matches version.py
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Assert release tag matches version.py
env:
TAG: ${{ github.event.release.tag_name }}
run: |
version="$(python3 -c 'import pathlib,re; print(re.search(r"__version__\s*=\s*\"([^\"]+)\"", pathlib.Path("packages/pybammsolvers/src/pybammsolvers/version.py").read_text()).group(1))')"
expected="pybammsolvers-v${version}"
if [ "$TAG" != "$expected" ]; then
echo "::error::Release tag '$TAG' does not match version.py ('$version', expected '$expected'). Bump version.py or fix the tag."
exit 1
fi
# version.py is the source of truth; pyproject.toml and vcpkg.json
# carry static mirrors. Delegate the drift check to the sync hook
# itself (--check verifies without rewriting) so the "where the
# version lives in each file" logic has a single home.
if ! python3 packages/pybammsolvers/scripts/sync_version.py --check; then
echo "::error::Static version mirrors are out of sync with version.py ('$version'). Run the sync-pybammsolvers-version pre-commit hook."
exit 1
fi
echo "Release tag '$TAG' matches version.py ($version); pyproject.toml and vcpkg.json are in sync."
publish_pypi:
if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'pybammsolvers-v') }}
name: Upload package to PyPI
needs: [ build, check_version ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pybammsolvers
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts
merge-multiple: true
- name: Sanity check downloaded artifacts
run: ls -lA artifacts/
working-directory: ${{ github.workspace }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: artifacts/