Skip to content

Commit 5cd625e

Browse files
committed
add github actions for release
1 parent 879be7c commit 5cd625e

3 files changed

Lines changed: 165 additions & 0 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
workflow_run:
13+
workflows: [Create Release]
14+
types:
15+
- completed
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
release-build:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
27+
- uses: actions/setup-python@v6
28+
with:
29+
python-version: "3.x"
30+
31+
- name: build release distribution
32+
run: |
33+
python -m pip install build
34+
python -m build
35+
36+
- name: upload dists
37+
uses: actions/upload-artifact@v7
38+
with:
39+
name: release-dists
40+
path: dist/
41+
42+
pypi-publish:
43+
runs-on: ubuntu-latest
44+
needs:
45+
- release-build
46+
environment:
47+
name: pypi
48+
url: https://pypi.org/p/bs120xenet
49+
permissions:
50+
id-token: write
51+
52+
steps:
53+
- name: Retrieve release distributions
54+
uses: actions/download-artifact@v8
55+
with:
56+
name: release-dists
57+
path: dist/
58+
59+
- name: Publish release distributions to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+

.github/workflows/release-docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish Docs
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
deploy:
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
25+
runs-on: ubuntu-24.04
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Setup venv
31+
run: |
32+
python -m venv .venv
33+
. .venv/bin/activate
34+
python -m pip install -r docs/doc-requirements.txt
35+
36+
- name: Run Sphinx
37+
run: |
38+
. .venv/bin/activate
39+
python -m sphinx -an docs docs/_build
40+
41+
- name: Setup pages
42+
uses: actions/configure-pages@v5
43+
44+
- name: Upload artifact
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: 'docs/_build'
48+
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
required: true
8+
type: string
9+
release:
10+
description: "Whether to create a GitHub Release"
11+
type: boolean
12+
default: true
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup venv
25+
run: |
26+
python -m venv .venv
27+
. .venv/bin/activate
28+
python -m pip install build
29+
30+
- name: Build
31+
run: |
32+
. .venv/bin/activate
33+
python -m build
34+
35+
- name: Create Release
36+
shell: bash
37+
env:
38+
TAG_NAME: ${{ inputs.tag_name }}
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
release_args=(
42+
"$TAG_NAME"
43+
--title "${TAG_NAME}"
44+
--target "$GITHUB_SHA"
45+
--generate-notes
46+
)
47+
48+
# check for e.g., v1.1.0-rc0
49+
if [[ $TAG_NAME == *-* ]]; then
50+
release_args+=( --prerelease )
51+
fi
52+
53+
gh release create "${release_args[@]}" dist/*.whl

0 commit comments

Comments
 (0)