-
Notifications
You must be signed in to change notification settings - Fork 482
184 lines (158 loc) · 5.48 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: GH Release and NPM Publish
on:
workflow_dispatch:
push:
branches:
- 'next'
paths:
- 'libraries/**'
- 'internal/**'
- 'scripts/**'
- 'package.json'
- '.github/workflows/publish-package.yml'
- 'apps/gui/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install
run: pnpm install --frozen-lockfile
- name: Build Worker Relay
run: |
pnpm --filter @nostrwatch/worker-relay run clean
pnpm --filter @nostrwatch/worker-relay run tsc
pnpm --filter @nostrwatch/worker-relay run copy:wasm
pnpm --filter @nostrwatch/worker-relay run build:esm
- name: Build GUI
run: pnpm --filter @nostrwatch/gui build
- name: Check Artifact Size
run: du -sh libraries/**/dist internal/**/dist apps/gui/dist
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: built-packages
path: |
libraries/**/dist/
libraries/**/src/sqlite/sqlite3.wasm
libraries/**/package.json
internal/**/dist/
internal/**/package.json
apps/gui/dist/
apps/gui/package.json
publish:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- package: 'nostrings'
- package: 'announce'
- package: 'logger'
- package: 'seed'
- package: 'utils'
- package: 'nwcache'
- package: 'controlflow'
- package: 'publisher'
- package: 'nocap'
- package: 'nocap-websocket-adapter-default'
- package: 'nocap-websocket-browser-adapter-default'
- package: 'nocap-info-adapter-default'
- package: 'nocap-dns-adapter-default'
- package: 'nocap-geo-adapter-default'
- package: 'nocap-ssl-adapter-default'
- package: 'nocap-every-adapter-default'
- package: 'worker-relay'
- package: 'gui'
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: built-packages
path: .
- name: Install Dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Install jq
if: matrix.package == 'gui'
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get package version (GUI)
if: matrix.package == 'gui'
id: get_version
run: |
VERSION=$(jq -r '.version' ./apps/gui/package.json)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Prepare Directories (GUI)
if: matrix.package == 'gui'
run: |
VERSION=${{ env.VERSION }}
echo "Deploying version $VERSION"
ssh -i ${{ secrets.GUI_SSH_KEY }} -o StrictHostKeyChecking=no ${{ secrets.GUI_HOST_USER }}@${{ secrets.GUI_HOST_IP }} << EOF
set -e
mkdir -p /var/www/${VERSION}
rm -rf /var/www/html/
ln -s /var/www/${VERSION} /var/www/html
EOF
- name: Upload Build (GUI)
if: matrix.package == 'gui'
run: |
scp -i ${{ secrets.GUI_SSH_KEY }} -o StrictHostKeyChecking=no -r ./apps/gui/dist/* ${{ secrets.GUI_HOST_USER }}@${{ secrets.GUI_HOST_IP }}:/var/www/html/${{ env.VERSION }}
- name: Find Package
id: find_package
run: |
PKG_PATH=$(find libraries internal apps -type d -name "${{ matrix.package }}" -print -quit)
echo "the_path=$PKG_PATH" >> "$GITHUB_OUTPUT"
- name: Publish Package
id: publish
if: matrix.package != 'gui'
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: ${{ steps.find_package.outputs.the_path }}/package.json
strategy: all
access: public
- name: Set Meta
id: meta
run: |
RELEASE_SLUG="${{ matrix.package }}@v${{ steps.publish.outputs.version }}"
echo "release_slug=$RELEASE_SLUG" >> "$GITHUB_OUTPUT"
- name: Archive Subdirectory
id: archive
run: |
zip -r "${{ steps.meta.outputs.release_slug }}.zip" "${{ steps.find_package.outputs.the_path }}"
- name: Create Release ${{ steps.meta.outputs.release_slug }}
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.meta.outputs.release_slug }}
release_name: ${{ steps.meta.outputs.release_slug }}
body: ""
draft: false
prerelease: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.meta.outputs.release_slug }}.zip
asset_name: ${{ steps.meta.outputs.release_slug }}.zip
asset_content_type: application/zip