Skip to content

Commit 9d5afea

Browse files
committed
Refactor WASM npm packaging and publishing process
1 parent c656fa5 commit 9d5afea

File tree

1 file changed

+57
-59
lines changed

1 file changed

+57
-59
lines changed

.github/workflows/main.yml

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -144,66 +144,11 @@ jobs:
144144
with:
145145
path: coverage
146146

147-
- name: wasm npm pack
148-
if: matrix.name == 'wasm'
149-
run: |
150-
TAG=$(git ls-remote --tags https://github.com/sqlite/sqlite-wasm.git | \
151-
awk -v ver=$(make sqlite_version) -F'/' '$NF ~ ver"-build[0-9]+$" {print $NF}' | \
152-
sort -V | \
153-
tail -n1)
154-
git clone --branch "$TAG" --depth 1 https://github.com/sqlite/sqlite-wasm.git sqlite-wasm
155-
rm -rf sqlite-wasm/sqlite-wasm/*
156-
unzip dist/sqlite-wasm.zip -d sqlite-wasm/tmp
157-
mv sqlite-wasm/tmp/sqlite-wasm-*/jswasm sqlite-wasm/sqlite-wasm
158-
159-
cd sqlite-wasm && npm i && npm run fix && npm run publint && npm run check-types && cd ..
160-
161-
PKG=sqlite-wasm/package.json
162-
TMP=sqlite-wasm/package.tmp.json
163-
164-
DESC="SQLite Wasm compiled with the automatically initialized cloudsync extension. Conveniently packaged as an ES Module for effortless integration."
165-
166-
jq \
167-
--arg name "@sqliteai/cloudsync-wasm" \
168-
--arg version "$(make sqlite_version)-cloudsync-$(make version)" \
169-
--arg desc "$DESC" \
170-
--argjson keywords '["offsync","cloudsync","sqliteai"]' \
171-
--arg repo_url "git+https://github.com/sqliteai/sqlite-sync.git" \
172-
--arg author "Gioele Cantoni ([email protected])" \
173-
--arg bugs_url "https://github.com/sqliteai/sqlite-sync/issues" \
174-
--arg homepage "https://github.com/sqliteai/sqlite-sync#readme" \
175-
'
176-
.name = $name
177-
| .version = $version
178-
| .description = $desc
179-
| .keywords += $keywords
180-
| del(.bin)
181-
| .scripts |= with_entries(select(
182-
.key != "build"
183-
and .key != "start"
184-
and .key != "start:node"
185-
and .key != "prepublishOnly"
186-
and .key != "deploy"
187-
))
188-
| .repository.url = $repo_url
189-
| .author = $author
190-
| .bugs.url = $bugs_url
191-
| .homepage = $homepage
192-
| del(.devDependencies.decompress)
193-
| del(.devDependencies["http-server"])
194-
| del(.devDependencies.shx)
195-
' "$PKG" > "$TMP" && mv "$TMP" "$PKG"
196-
197-
sed 's/@sqlite\.org\/sqlite-wasm/@sqliteai\/cloudsync-wasm/g' sqlite-wasm/README.md > sqlite-wasm/README.tmp
198-
echo -e "# sqlite-sync WASM $(make version)\nThis README and the TypeScript types are from the [official SQLite wasm repository](https://github.com/sqlite/sqlite-wasm)\n\n$(cat sqlite-wasm/README.tmp)" > sqlite-wasm/README.md
199-
rm -rf sqlite-wasm/tmp sqlite-wasm/bin sqlite-wasm/demo sqlite-wasm/README.tmp sqlite-wasm/package-lock.json
200-
cd sqlite-wasm && npm pack
201-
202147
- uses: actions/[email protected]
203148
if: always()
204149
with:
205150
name: cloudsync-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
206-
path: ${{ matrix.name == 'wasm' && 'sqlite-wasm/*.tgz' || 'dist/cloudsync.*'}}
151+
path: dist/${{ matrix.name == 'wasm' && 'sqlite-wasm.zip' || 'cloudsync.*'}}
207152
if-no-files-found: error
208153

209154
release:
@@ -255,18 +200,70 @@ jobs:
255200
for folder in "artifacts"/*; do
256201
if [ -d "$folder" ]; then
257202
name=$(basename "$folder")
258-
if [[ "$name" != "github-pages" ]]; then
203+
if [[ "$name" != "github-pages" && "$name" != "cloudsync-wasm" ]]; then
259204
zip -jq "${name}-${{ steps.tag.outputs.version }}.zip" "$folder"/*
260205
tar -cJf "${name}-${{ steps.tag.outputs.version }}.tar.xz" -C "$folder" .
261206
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
262207
fi
263208
fi
264209
done
210+
cp artifacts/cloudsync-wasm/sqlite-wasm.zip "sqlite-$(make sqlite_version)-sync-${{ steps.tag.outputs.version }}-wasm.zip"
265211
266212
- name: wasm publish to npmjs
267213
if: steps.tag.outputs.version != ''
268-
#use this version when the repo will become public run: npm publish --provenance --access public ./artifacts/cloudsync-wasm/sqlite-wasm/sqliteai-cloudsync-wasm-*-cloudsync-*.tgz
269-
run: npm publish --access public ./artifacts/cloudsync-wasm/sqlite-wasm/sqliteai-cloudsync-wasm-*-cloudsync-*.tgz
214+
run: |
215+
TAG=$(git ls-remote --tags https://github.com/sqlite/sqlite-wasm.git | \
216+
awk -v ver=$(make sqlite_version) -F'/' '$NF ~ ver"-build[0-9]+$" {print $NF}' | \
217+
sort -V | \
218+
tail -n1)
219+
git clone --branch "$TAG" --depth 1 https://github.com/sqlite/sqlite-wasm.git sqlite-wasm
220+
rm -rf sqlite-wasm/sqlite-wasm/*
221+
unzip artifacts/cloudsync-wasm/sqlite-wasm.zip -d sqlite-wasm/tmp
222+
mv sqlite-wasm/tmp/sqlite-wasm-*/jswasm sqlite-wasm/sqlite-wasm
223+
224+
cd sqlite-wasm && npm i && npm run fix && npm run publint && npm run check-types && cd ..
225+
226+
PKG=sqlite-wasm/package.json
227+
TMP=sqlite-wasm/package.tmp.json
228+
229+
DESC="SQLite Wasm compiled with the automatically initialized sqlite-sync extension. Conveniently packaged as an ES Module for effortless integration."
230+
231+
jq \
232+
--arg name "@sqliteai/sqlite-sync-wasm" \
233+
--arg version "$(make sqlite_version)-sync-$(make version)" \
234+
--arg desc "$DESC" \
235+
--argjson keywords '["sync","offsync","cloudsync","sqliteai"]' \
236+
--arg repo_url "git+https://github.com/sqliteai/sqlite-sync.git" \
237+
--arg author "Gioele Cantoni ([email protected])" \
238+
--arg bugs_url "https://github.com/sqliteai/sqlite-sync/issues" \
239+
--arg homepage "https://github.com/sqliteai/sqlite-sync#readme" \
240+
'
241+
.name = $name
242+
| .version = $version
243+
| .description = $desc
244+
| .keywords += $keywords
245+
| del(.bin)
246+
| .scripts |= with_entries(select(
247+
.key != "build"
248+
and .key != "start"
249+
and .key != "start:node"
250+
and .key != "prepublishOnly"
251+
and .key != "deploy"
252+
))
253+
| .repository.url = $repo_url
254+
| .author = $author
255+
| .bugs.url = $bugs_url
256+
| .homepage = $homepage
257+
| del(.devDependencies.decompress)
258+
| del(.devDependencies["http-server"])
259+
| del(.devDependencies.shx)
260+
' "$PKG" > "$TMP" && mv "$TMP" "$PKG"
261+
262+
sed 's/@sqlite\.org\/sqlite-wasm/@sqliteai\/sqlite-sync-wasm/g' sqlite-wasm/README.md > sqlite-wasm/README.tmp
263+
echo -e "# sqlite-sync WASM $(make version)\nThis README and the TypeScript types are from the [official SQLite wasm repository](https://github.com/sqlite/sqlite-wasm)\n\n$(cat sqlite-wasm/README.tmp)" > sqlite-wasm/README.md
264+
rm -rf sqlite-wasm/tmp sqlite-wasm/bin sqlite-wasm/demo sqlite-wasm/README.tmp sqlite-wasm/package-lock.json
265+
cd sqlite-wasm && npm publish --access public
266+
#add --provenance to npm publish when the repo will be public
270267
env:
271268
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
272269

@@ -279,4 +276,5 @@ jobs:
279276
cloudsync-*-${{ steps.tag.outputs.version }}.zip
280277
cloudsync-*-${{ steps.tag.outputs.version }}.tar.xz
281278
cloudsync-*-${{ steps.tag.outputs.version }}.tar.gz
279+
sqlite-*-sync-${{ steps.tag.outputs.version }}-wasm.zip
282280
make_latest: true

0 commit comments

Comments
 (0)