-
Notifications
You must be signed in to change notification settings - Fork 593
163 lines (134 loc) Β· 4.41 KB
/
publish-package.yml
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
154
155
156
157
158
159
160
161
162
163
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Release and publish
on:
workflow_dispatch:
push:
branches:
- main
- dev
jobs:
bump:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.changesets.outputs.publishedPackages }}
steps:
- uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ secrets.CHANGESETS_PUSH_PAT }}
- uses: pnpm/action-setup@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install pnpm dependencies
run: pnpm install
- name: Ensure release mode
id: release_mode
run: |
set +e
pnpm changeset pre ${{ github.ref == '/refs/heads/main' && 'exit' || 'enter dev' }}
echo "exitcode=$?" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add changes
if: ${{ steps.release_mode.outputs.exitcode == '0' }}
uses: EndBug/add-and-commit@v9
with:
add: '[".changeset"]'
default_author: github_actions
message: ${{ github.ref == '/refs/heads/main' && 'Exit' || 'Enter dev' }} pre release mode
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
version: pnpm ci:version
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: debug packages
run: echo "${{ steps.changesets.outputs.publishedPackages }}"
debug-outputs:
needs:
- bump
runs-on: ubuntu-latest
steps:
- name: Echo outputs
run: echo "${{needs.bump.outputs.packages}}"
build:
needs:
- bump
strategy:
matrix:
package: ${{ fromJson(needs.bump.outputs.packages) }}
defaults:
run:
working-directory: ${{ matrix.package.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Bump version.py
run: |
export module=$(sed 's/^.*\///' <<< ${{ matrix.package.name }} | tr '-' '/')
export version=$(sed 's|-\([0-9]*\)$|\1|' <<< ${{ matrix.package.version }})
sed -i "s/__version__.*/__version__ = \"$version\"/" $module/version.py
- name: Build package
run: python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: ${{ matrix.package.name }}/dist/
publish:
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
docs:
needs:
- bump
- publish
strategy:
matrix:
package: ${{ fromJSON(needs.bump.outputs.packages) }}
runs-on: ubuntu-latest
env:
package: $(sed 's/^.*\///' <<< ${{ matrix.package.name }})
module: $(tr '-' '/' <<< $package)
steps:
- uses: actions/checkout@v3
- name: Install pdoc
run: python -m pip install --upgrade pdoc
- name: Install package
run: python -m pip install $package/
- name: Build Docs
run: python -m pdoc $module --docformat=google --output-dir docs
- name: S3 Upload
run: aws s3 cp docs/ s3://livekit-docs/$package --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
AWS_DEFAULT_REGION: "us-east-1"