Skip to content

Commit 337e0bd

Browse files
committed
Update workflows
1 parent d6e4599 commit 337e0bd

File tree

5 files changed

+160
-1
lines changed

5 files changed

+160
-1
lines changed

.github/workflows/docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build Docs
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Lint and Format Code"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.head_ref }}
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.10"
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -e ".[docs]"
31+
32+
- name: Convert notebooks to markdown for docs
33+
run: |
34+
jupyter nbconvert --to markdown "examples/cookbook.ipynb" --output-dir="docs/cookbook"
35+
36+
- name: Commit changes
37+
run: |
38+
git config --local user.email "action@github.com"
39+
git config --local user.name "GitHub Action"
40+
git add -A
41+
if git diff --exit-code --staged; then
42+
echo "No changes to commit"
43+
else
44+
git commit -m "[GitHub Action] Converted notebooks to markdown for docs"
45+
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
46+
fi
47+
48+
- name: Add remote
49+
run: git remote add pkg "https://github.com/WecoAI/aifn-python.git"
50+
51+
- name: Build and deploy
52+
run: |
53+
mkdocs gh-deploy --force -c -v

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install -e ".[docs]"
26+
pip install -e ".[dev]"
2727
2828
- name: Run linter
2929
run: |

.github/workflows/release.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Publish Python Package
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Lint and Format Code"]
6+
types:
7+
- completed
8+
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
build:
14+
name: Build distribution 📦
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.head_ref }}
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.10"
27+
28+
- name: Install build dependencies
29+
run: >-
30+
python3 -m pip install build --user
31+
32+
- name: Build a source distribution and a wheel
33+
run: python3 -m build
34+
35+
- name: Store the distribution packages
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: python-package-distributions
39+
path: dist/
40+
41+
publish-to-pypi:
42+
name: >-
43+
Publish Python 🐍 distribution PyPI
44+
needs:
45+
- build
46+
runs-on: ubuntu-latest
47+
environment:
48+
name: release
49+
url: https://pypi.org/p/aifn
50+
permissions:
51+
id-token: write
52+
53+
steps:
54+
- name: Download the dists
55+
uses: actions/download-artifact@v3
56+
with:
57+
name: python-package-distributions
58+
path: dist/
59+
60+
- name: Publish to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
63+
github-release:
64+
name: >-
65+
Create GitHub Release
66+
needs:
67+
- publish-to-pypi
68+
runs-on: ubuntu-latest
69+
70+
permissions:
71+
contents: write
72+
id-token: write
73+
74+
steps:
75+
- name: Download dists
76+
uses: actions/download-artifact@v3
77+
with:
78+
name: python-package-distributions
79+
path: dist/
80+
81+
- name: Sign dists with Sigstore
82+
uses: sigstore/gh-action-sigstore-python@v2.1.1
83+
with:
84+
inputs: >-
85+
./dist/*.tar.gz
86+
./dist/*.whl
87+
88+
- name: Create GitHub Release
89+
env:
90+
GITHUB_TOKEN: ${{ github.token }}
91+
run: >-
92+
gh release create
93+
'v0.2.0'
94+
--repo '${{ github.repository }}'
95+
--notes ""
96+
97+
- name: Upload artifact signatures to GitHub Release
98+
env:
99+
GITHUB_TOKEN: ${{ github.token }}
100+
# Upload to GitHub Release using the `gh` CLI.
101+
# `dist/` contains the built packages, and the
102+
# sigstore-produced signatures and certificates.
103+
run: >-
104+
gh release upload
105+
'v0.2.0' dist/**
106+
--repo '${{ github.repository }}'
-3.65 KB
Binary file not shown.
-3.67 KB
Binary file not shown.

0 commit comments

Comments
 (0)