-
Notifications
You must be signed in to change notification settings - Fork 2
81 lines (70 loc) · 2.21 KB
/
Copy pathrelease.yml
File metadata and controls
81 lines (70 loc) · 2.21 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
name: Build and publish release
on:
push:
tags:
- "v[0-9]*"
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Verify release tag matches package version
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
python - <<'PY'
import os
import re
from pathlib import Path
tag = os.environ["RELEASE_TAG"]
match = re.fullmatch(r"v(\d+\.\d+\.\d+)", tag)
source = Path("spectroview/__init__.py").read_text(encoding="utf-8")
version = re.search(r'^VERSION\s*=\s*["\']([^"\']+)["\']', source, re.M)
if not match or version is None or version.group(1) != match.group(1):
raise SystemExit(
"Release tags must be vMAJOR.MINOR.PATCH and match "
"spectroview.VERSION."
)
PY
- name: Build and validate distributions
run: |
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: python-distributions
path: dist/
if-no-files-found: error
- name: Create GitHub release and attach distributions
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" dist/* \
--repo "$GITHUB_REPOSITORY" \
--title "$GITHUB_REF_NAME" \
--notes "The installable wheel is attached below and is used by SPECTROview's automatic updater." \
--generate-notes \
--verify-tag
publish-pypi:
needs: build-and-release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/spectroview
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-distributions
path: dist/
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1