-
Notifications
You must be signed in to change notification settings - Fork 99
174 lines (151 loc) · 7.17 KB
/
Copy pathlexical-graph-release.yml
File metadata and controls
174 lines (151 loc) · 7.17 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This workflow builds the lexical-graph package on prerelease and release events.
#
# This workflow will upload a Python Package to PyPI when a release is created (not prerelease)
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
#
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Lexical Graph Release
on:
release:
types: [prereleased, released]
permissions:
contents: write
attestations: write
id-token: write
jobs:
release-build:
# Constraint: Only run if the tag starts with 'graphrag-lexical-graph/v':
if: startsWith(github.ref, 'refs/tags/graphrag-lexical-graph/v')
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.pypi_version }}
defaults:
run:
working-directory: lexical-graph
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- name: Create virtual environment
run: uv venv .venv
- name: Install build dependencies
run: uv pip install --python .venv/bin/python build
- name: Build package
run: .venv/bin/python -m build
- name: Create latest dist copies
run: |
cp dist/*.whl dist/lexical-graph-latest.whl
cp dist/*.tar.gz dist/lexical-graph-latest.tar.gz
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: lexical-graph-dist
path: lexical-graph/dist/
- name: Extract version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF_NAME#graphrag-lexical-graph/}"
else
VERSION="v$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "pypi_version=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Zip lexical-graph notebooks
working-directory: examples/lexical-graph/notebooks
run: |
zip lexical-graph-examples.zip *.ipynb
cp lexical-graph-examples.zip lexical-graph-examples-${{ steps.version.outputs.version }}.zip
cp lexical-graph-examples.zip lexical-graph-examples-latest.zip
- name: Upload lexical-graph-examples.zip
uses: actions/upload-artifact@v7
with:
name: lexical-graph-examples
path: |
examples/lexical-graph/notebooks/lexical-graph-examples.zip
examples/lexical-graph/notebooks/lexical-graph-examples-${{ steps.version.outputs.version }}.zip
examples/lexical-graph/notebooks/lexical-graph-examples-latest.zip
retention-days: 30
- name: Zip lexical-graph-hybrid-dev notebooks
working-directory: examples/lexical-graph-hybrid-dev/notebooks
run: |
zip lexical-graph-hybrid-dev-examples.zip *.ipynb
cp lexical-graph-hybrid-dev-examples.zip lexical-graph-hybrid-dev-examples-${{ steps.version.outputs.version }}.zip
cp lexical-graph-hybrid-dev-examples.zip lexical-graph-hybrid-dev-examples-latest.zip
- name: Upload lexical-graph-hybrid-dev-examples.zip
uses: actions/upload-artifact@v7
with:
name: lexical-graph-hybrid-dev-examples
path: |
examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples.zip
examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples-${{ steps.version.outputs.version }}.zip
examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples-latest.zip
retention-days: 30
- name: Cleanup existing release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
TAG="$RELEASE_TAG"
# Extract base version (e.g. graphrag-lexical-graph/v3.18.0 from graphrag-lexical-graph/v3.18.0.dev3)
BASE_VERSION="${TAG%.dev*}"
# Find all dev releases matching this base version and delete their assets
gh release list --limit 100 --json tagName --jq '.[].tagName' | grep "^${BASE_VERSION}\.dev" | while read -r tag; do
gh release view "$tag" --json assets --jq '.assets[].name' | while read -r name; do
gh release delete-asset "$tag" "$name" --yes
done
done
- name: Generate checksums
working-directory: ${{ github.workspace }}
run: |
cd lexical-graph/dist && sha256sum *.whl *.tar.gz > SHA256SUMS && cd ${{ github.workspace }}
sha256sum examples/lexical-graph/notebooks/lexical-graph-examples-${{ steps.version.outputs.version }}.zip | sed 's|.*/||' >> lexical-graph/dist/SHA256SUMS
sha256sum examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples-${{ steps.version.outputs.version }}.zip | sed 's|.*/||' >> lexical-graph/dist/SHA256SUMS
- name: Attest build provenance
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
with:
subject-path: |
lexical-graph/dist/*.whl
lexical-graph/dist/*.tar.gz
lexical-graph/dist/SHA256SUMS
examples/lexical-graph/notebooks/lexical-graph-examples-${{ steps.version.outputs.version }}.zip
examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples-${{ steps.version.outputs.version }}.zip
- name: Attach Artifacts to GitHub Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
files: |
lexical-graph/dist/*
examples/lexical-graph/notebooks/lexical-graph-examples-${{ steps.version.outputs.version }}.zip
examples/lexical-graph/notebooks/lexical-graph-examples-latest.zip
examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples-${{ steps.version.outputs.version }}.zip
examples/lexical-graph-hybrid-dev/notebooks/lexical-graph-hybrid-dev-examples-latest.zip
prerelease: ${{ github.event.action == 'prereleased' }}
pypi-publish:
if: github.event.action == 'released'
runs-on: ubuntu-latest
needs: release-build
permissions:
id-token: write
attestations: write
environment:
name: pypi
url: https://pypi.org/project/graphrag-lexical-graph/${{ needs.release-build.outputs.version }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: lexical-graph-dist
path: dist/
- name: Remove non-versioned dist copies
run: rm -f dist/*-latest.*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
with:
attestations: true