Skip to content

Commit 2baeff2

Browse files
authored
[CI] New publish workflow (#66)
1 parent 6432680 commit 2baeff2

File tree

2 files changed

+69
-68
lines changed

2 files changed

+69
-68
lines changed

.github/workflows/publish.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
on:
2+
release:
3+
types:
4+
[published]
5+
6+
jobs:
7+
publish_pypi:
8+
name: Publish package to PyPI
9+
runs-on: ubuntu-latest
10+
permissions:
11+
# IMPORTANT: this permission is mandatory for trusted publishing
12+
id-token: write
13+
steps:
14+
- name: Check out QEK
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.ref }}
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.10"
22+
- name: Install Python dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install hatch
26+
- name: Build and publish package
27+
run: |
28+
hatch build
29+
- name: Publish to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
- name: Confirm deployment
32+
timeout-minutes: 5
33+
run: |
34+
VERSION=${GITHUB_REF#refs/tags/v}
35+
until pip download quantum-evolution-kernel==$VERSION
36+
do
37+
echo "Failed to download from PyPI, will wait for upload and retry."
38+
sleep 1
39+
done
40+
41+
public_docs:
42+
name: Publish docs to github pages
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout QEK
46+
uses: actions/checkout@v4
47+
- name: Install JetBrains Mono font
48+
run: |
49+
sudo apt install -y wget unzip fontconfig
50+
wget https://download.jetbrains.com/fonts/JetBrainsMono-2.304.zip
51+
unzip JetBrainsMono-2.304.zip -d JetBrainsMono
52+
mkdir -p /usr/share/fonts/truetype/jetbrains
53+
cp JetBrainsMono/fonts/ttf/*.ttf /usr/share/fonts/truetype/jetbrains/
54+
fc-cache -f -v
55+
- name: Install graphviz
56+
run: sudo apt-get install -y graphviz
57+
- name: Set up Python 3.10
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: '3.10'
61+
- name: Install Hatch
62+
run: |
63+
pip install hatch
64+
- name: Deploy docs
65+
run: |
66+
git config user.name "GitHub Actions"
67+
git config user.email "actions@github.com"
68+
git fetch origin gh-pages
69+
hatch -v run docs:mike deploy --push --update-aliases ${{ github.ref_name }} latest

.github/workflows/test.yml

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -130,71 +130,3 @@ jobs:
130130
foreach($tutorial in $files) {
131131
hatch run jupyter execute "$tutorial"
132132
}
133-
134-
publish:
135-
name: Publish to PyPI
136-
if: startsWith(github.ref, 'refs/tags/v')
137-
needs: test_qek
138-
runs-on: ubuntu-latest
139-
permissions:
140-
# IMPORTANT: this permission is mandatory for trusted publishing
141-
id-token: write
142-
steps:
143-
- name: Check out QEK
144-
uses: actions/checkout@v4
145-
with:
146-
ref: ${{ github.ref }}
147-
- name: Set up Python
148-
uses: actions/setup-python@v5
149-
with:
150-
python-version: "3.10"
151-
- name: Install Python dependencies
152-
run: |
153-
python -m pip install --upgrade pip
154-
pip install hatch
155-
- name: Build and publish package
156-
run: |
157-
hatch build
158-
- name: Publish to PyPI
159-
uses: pypa/gh-action-pypi-publish@release/v1
160-
- name: Confirm deployment
161-
timeout-minutes: 5
162-
run: |
163-
VERSION=${GITHUB_REF#refs/tags/v}
164-
until pip download quantum-evolution-kernel==$VERSION
165-
do
166-
echo "Failed to download from PyPI, will wait for upload and retry."
167-
sleep 1
168-
done
169-
170-
deploy_docs:
171-
name: Deploy QEK docs (ubuntu)
172-
if: startsWith(github.ref, 'refs/tags/v')
173-
needs: test_qek
174-
runs-on: ubuntu-latest
175-
steps:
176-
- name: Checkout QEK
177-
uses: actions/checkout@v4
178-
- name: Install JetBrains Mono font
179-
run: |
180-
sudo apt install -y wget unzip fontconfig
181-
wget https://download.jetbrains.com/fonts/JetBrainsMono-2.304.zip
182-
unzip JetBrainsMono-2.304.zip -d JetBrainsMono
183-
mkdir -p /usr/share/fonts/truetype/jetbrains
184-
cp JetBrainsMono/fonts/ttf/*.ttf /usr/share/fonts/truetype/jetbrains/
185-
fc-cache -f -v
186-
- name: Install graphviz
187-
run: sudo apt-get install -y graphviz
188-
- name: Set up Python 3.10
189-
uses: actions/setup-python@v5
190-
with:
191-
python-version: '3.10'
192-
- name: Install Hatch
193-
run: |
194-
pip install hatch
195-
- name: Deploy docs
196-
run: |
197-
git config user.name "GitHub Actions"
198-
git config user.email "actions@github.com"
199-
git fetch origin gh-pages
200-
hatch -v run docs:mike deploy --push --update-aliases ${{ github.ref_name }} latest

0 commit comments

Comments
 (0)