Repository navigation
113 lines (106 loc) · 3.7 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (106 loc) · 3.7 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: release
# On a version tag this builds the package once, publishes it to PyPI via
# trusted publishing (no API token stored in the repo), and attaches the built
# wheel and sdist downloaded back from PyPI to a GitHub Release for the tag.
# Both downloads must match the checked build. The PyPI project must list
# this repo and workflow as a trusted publisher first.
on:
push:
# PyGAD tags releases as the bare version number, e.g. 3.6.0 (no "v").
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: read
jobs:
tests:
uses: ./.github/workflows/main.yml
permissions:
contents: read
build:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Verify release tag matches package version
run: |
python - <<'PY'
import os
import runpy
version = runpy.run_path("pygad/_version.py")["__version__"]
tag = os.environ["GITHUB_REF_NAME"]
if tag != version:
raise SystemExit(f"Release tag {tag} does not match package version {version}")
PY
- name: Build distributions
run: |
pip install build . pytest responses 'vilvik>=0.5.3'
python -m pytest tests/test_push_to_vilvik.py tests/test_vilvik_compatibility.py -q
python -m build
- name: Check distributions
run: |
pip install twine
python -m twine check dist/*
- name: Check documentation
run: |
pip install -r docs/requirements.txt
python docs/markdown_compatibility.py
python -m sphinx -b html -W --keep-going docs/source docs/build/html
- name: Prepare documented release notes
run: python tools/release.py notes "$GITHUB_REF_NAME" release-notes.md
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
- uses: actions/upload-artifact@v4
with:
name: release-notes
path: release-notes.md
publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
needs: [build, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: actions/download-artifact@v4
with:
name: release-notes
- name: Download and verify the published PyPI distributions
run: python tools/release.py fetch-pypi "$GITHUB_REF_NAME" dist published-dist
- name: Publish GitHub release with documented notes and PyPI files
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" published-dist/* \
--repo "$GITHUB_REPOSITORY" --clobber
gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
--title "PyGAD $GITHUB_REF_NAME" --notes-file release-notes.md --draft=false --latest
else
gh release create "$GITHUB_REF_NAME" published-dist/* \
--repo "$GITHUB_REPOSITORY" --verify-tag --latest \
--title "PyGAD $GITHUB_REF_NAME" --notes-file release-notes.md
fi