-
Notifications
You must be signed in to change notification settings - Fork 190
135 lines (113 loc) · 4.15 KB
/
publish.yml
File metadata and controls
135 lines (113 loc) · 4.15 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
name: Publish to PyPI
on:
push:
tags: ['v*']
permissions:
contents: write # needed for creating GitHub releases
jobs:
# ---------------------------------------------------------------------------
# Build the Next.js frontend as a standalone tarball
# ---------------------------------------------------------------------------
build-web:
name: Build Web UI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci --workspace packages/web
- name: Build Next.js (standalone)
run: npm run build --workspace packages/web
env:
NEXT_PUBLIC_REPOWISE_API_URL: ""
- name: Package standalone output
run: |
STANDALONE=packages/web/.next/standalone
# Copy static assets into standalone (Next.js requirement)
cp -r packages/web/.next/static $STANDALONE/packages/web/.next/static
[ -d packages/web/public ] && cp -r packages/web/public $STANDALONE/packages/web/public || true
# Flatten: move the nested server into a clean directory
mkdir -p /tmp/repowise-web
cp $STANDALONE/packages/web/server.js /tmp/repowise-web/
cp -r $STANDALONE/packages/web/.next /tmp/repowise-web/.next
[ -d $STANDALONE/packages/web/public ] && cp -r $STANDALONE/packages/web/public /tmp/repowise-web/public || true
cp -r $STANDALONE/node_modules /tmp/repowise-web/node_modules 2>/dev/null || true
[ -d $STANDALONE/packages/web/node_modules ] && cp -r $STANDALONE/packages/web/node_modules/* /tmp/repowise-web/node_modules/ 2>/dev/null || true
# Create tarball
cd /tmp/repowise-web && tar -czf /tmp/repowise-web.tar.gz .
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
name: repowise-web
path: /tmp/repowise-web.tar.gz
# ---------------------------------------------------------------------------
# Build the Python package
# ---------------------------------------------------------------------------
build-python:
name: Build Python package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install build
- name: Build sdist and wheel
run: python -m build
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
# ---------------------------------------------------------------------------
# Create GitHub release with web UI tarball
# ---------------------------------------------------------------------------
release:
name: Create GitHub Release
needs: [build-web, build-python]
runs-on: ubuntu-latest
steps:
- name: Download web artifact
uses: actions/download-artifact@v4
with:
name: repowise-web
path: ./artifacts/
- name: Download Python dist
uses: actions/download-artifact@v4
with:
name: dist
path: ./dist/
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/repowise-web.tar.gz
dist/*
generate_release_notes: true
# ---------------------------------------------------------------------------
# Publish to PyPI
# ---------------------------------------------------------------------------
publish:
name: Publish to PyPI
needs: build-python
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # trusted publishing (OIDC)
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true