-
Notifications
You must be signed in to change notification settings - Fork 147
140 lines (119 loc) · 3.72 KB
/
publish.yaml
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
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
#
# Publish PyPI and NPM artifacts
#
name: Publish
on:
pull_request:
paths-ignore:
- "docs/**"
- "contrib/**"
- "**.md"
- ".github/workflows/*"
- "!.github/workflows/publish.yaml"
push:
paths-ignore:
- "docs/**"
- "contrib/**"
- "**.md"
- ".github/workflows/*"
- "!.github/workflows/publish.yaml"
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
tags:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/setup-node@v4
with:
cache: yarn
node-version: "lts/*"
registry-url: https://registry.npmjs.org
cache-dependency-path: labextension/yarn.lock
- name: Update root build packages
run: |
pip install --upgrade build pip
- name: Build dist
run: |
pyproject-build
cd dist && sha256sum * | tee SHA256SUMS
- name: Check dist sizes
run: |
set -eux
ls -lathr dist
[[ $(find dist -type f -size +200k) ]] && exit 1 || echo ok
- name: Javascript package
run: |
mkdir jsdist
cd jsdist
npm pack ../labextension
sha256sum * | tee SHA256SUMS
- name: Upload Python artifact
uses: actions/upload-artifact@v4
with:
name: dist-${{ github.run_attempt }}
path: dist
if-no-files-found: error
- name: Upload Javascript artifact
uses: actions/upload-artifact@v4
with:
name: jsdist-${{ github.run_attempt }}
path: jsdist
if-no-files-found: error
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
publish-pypi:
runs-on: ubuntu-22.04
needs:
- build
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download artifacts from build
uses: actions/download-artifact@v4
with:
name: dist-${{ github.run_attempt }}
path: dist
# The PyPI publishing action will try to publish this checksum file as if
# it was a Python package if it remains in dist, so we clean it up first.
- name: Cleanup SHA256SUMS
run: |
cat dist/SHA256SUMS
rm dist/SHA256SUMS
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}
# https://docs.github.com/en/actions/language-and-framework-guides/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
publish-npm:
runs-on: ubuntu-22.04
needs:
- build
steps:
# actions/setup-node creates an .npmrc file that references NODE_AUTH_TOKEN
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
registry-url: https://registry.npmjs.org
- name: Download artifacts from build
uses: actions/download-artifact@v4
with:
name: jsdist-${{ github.run_attempt }}
path: jsdist
- run: |
npm publish --dry-run ./jsdist/jupyterhub-jupyter-server-proxy-*.tgz
- run: |
npm publish ./jsdist/jupyterhub-jupyter-server-proxy-*.tgz
if: startsWith(github.ref, 'refs/tags')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}