Skip to content

Commit d7782a8

Browse files
authored
Add release workflow (#269)
1 parent 2d39f64 commit d7782a8

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CD
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "0 3 * * 1"
9+
10+
env:
11+
FORCE_COLOR: 3
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
# include tags so that hatch-vcs can infer the version
20+
fetch-depth: 0
21+
# switch to fetch-tags: true when the following is fixed
22+
# see https://github.com/actions/checkout/issues/2041
23+
# fetch-tags: true
24+
25+
- name: Setup Python
26+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
27+
with:
28+
python-version: "3.12"
29+
30+
- name: Build
31+
run: |
32+
python -m pip install build
33+
python -m build .
34+
35+
- name: Store the distribution packages
36+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
37+
with:
38+
name: python-package-distributions
39+
path: dist/
40+
if-no-files-found: error
41+
42+
publish:
43+
name: Publish to PyPI
44+
needs: [build]
45+
runs-on: ubuntu-latest
46+
if: github.event_name == 'release' && github.event.action == 'published'
47+
environment:
48+
name: pypi
49+
url: https://pypi.org/p/sphinx-js
50+
permissions:
51+
id-token: write # IMPORTANT: mandatory for trusted publishing
52+
attestations: write
53+
contents: read
54+
steps:
55+
- name: Download all the dists
56+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
57+
with:
58+
path: dist/
59+
merge-multiple: true
60+
61+
- name: Generate artifact attestations
62+
uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2.3.0
63+
with:
64+
subject-path: "dist/*"
65+
66+
- name: Publish distribution 📦 to PyPI
67+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

0 commit comments

Comments
 (0)