-
Notifications
You must be signed in to change notification settings - Fork 36
153 lines (144 loc) · 4.95 KB
/
pythonpublish.yml
File metadata and controls
153 lines (144 loc) · 4.95 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
# To create a release:
# - make sure /.SETUPTOOLS_SCM_PRETEND_VERSION is up to date
# - commit the changes
# - create an annotated tag with the version number, e.g.: git tag -a v2.0.1 -m "v2.0.1"
# - push the tag, which will trigger this pythonpublish release workflow and hatch build will build and publish using the tag version
# - note: only builds from tagged commits will have proper release versions, others will have dev versions
name: Publish g2p to PyPI and create a GitHub release
on:
push:
tags:
# We publish only actual releases, not dev, alpha or beta versions
- v[0-9]+.[0-9]+.[0-9]+
jobs:
tests:
uses: ./.github/workflows/tests.yml
secrets: inherit
matrix-tests:
uses: ./.github/workflows/matrix-tests.yml
secrets: inherit
build:
runs-on: ubuntu-latest
needs: tests
permissions:
contents: read
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Validate version consistency
run: |
echo .SETUPTOOLS_SCM_PRETEND_VERSION=$(cat .SETUPTOOLS_SCM_PRETEND_VERSION)
echo github.ref_name=${GITHUB_REF_NAME}
test v$(cat .SETUPTOOLS_SCM_PRETEND_VERSION) == $(echo ${GITHUB_REF_NAME} | cut -d. -f1-2)
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install build tool
run: pip install build
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
github-release:
name: Make a signed GitHub release
needs:
- tests
- matrix-tests
- build
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
name: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}
deploy-docs:
runs-on: ubuntu-latest
needs:
- github-release
permissions:
contents: write # to deploy to gh-pages
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # fetch all commits/branches
persist-credentials: true # so we can deploy to gh-pages
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[docs]
- name: Setup doc deploy
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Deploy docs with mike 🚀
run: |
mike deploy --push --update-aliases ${GITHUB_REF_NAME} stable latest
publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- github-release
- deploy-docs
environment:
name: pypi
url: https://pypi.org/p/g2p
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download the distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# Convertextract depends on g2p<2.0, maybe this is no longer relevant?
# Or do we want to keep it because eventually convertextract will depend on g2p>=2.0?
trigger-convertextract-build:
runs-on: ubuntu-latest
needs: publish-to-pypi
steps:
- name: trigger convertextract build
run: |
curl --location --request POST 'https://api.github.com/repos/roedoejet/convertextract/dispatches' \
--header 'Accept: application/vnd.github.everest-preview+json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${{ secrets.G2P_PAT }}' \
--header 'Content-Type: text/plain' \
--data-raw '{
"event_type": "g2p-published",
"client_payload": {}
}'