Skip to content

Commit 9869343

Browse files
feat: CLI installers and Package Publishing (#8)
1 parent 928bf98 commit 9869343

31 files changed

Lines changed: 2493 additions & 123 deletions

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [["powersync", "@powersync/cli-core", "@powersync/cli-schemas", "@powersync/cli-plugin-docker"]],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.changeset/shaggy-parks-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'powersync': patch
3+
---
4+
5+
[Internal] Configure trusted publishing and Github release flow.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build CLI Installer Artifacts Partial
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
retention-days:
7+
description: 'Number of days to retain uploaded artifacts'
8+
type: number
9+
default: 7
10+
11+
jobs:
12+
package-installers:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: macos-latest
18+
command: pack macos
19+
artifact_name: macos-pkg
20+
artifact_path: cli/dist/**/*.pkg
21+
- os: windows-latest
22+
command: pack win --targets win32-x64
23+
artifact_name: windows-installer
24+
artifact_path: cli/dist/**/*.exe
25+
- os: ubuntu-latest
26+
command: pack deb
27+
artifact_name: linux-deb
28+
artifact_path: cli/dist/**/*.deb
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: pnpm/action-setup@v4
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version-file: '.nvmrc'
36+
cache: 'pnpm'
37+
- name: Configure pnpm linker for Windows packaging
38+
if: ${{ matrix.os == 'windows-latest' }}
39+
shell: pwsh
40+
run: Set-Content -Path cli/.npmrc -Value "node-linker=hoisted"
41+
- run: pnpm install --frozen-lockfile
42+
- run: pnpm run build
43+
- name: Install Windows packaging dependencies
44+
if: ${{ matrix.os == 'windows-latest' }}
45+
run: choco install nsis.portable 7zip grep --no-progress -y
46+
- name: Verify Windows packaging dependencies
47+
if: ${{ matrix.os == 'windows-latest' }}
48+
shell: pwsh
49+
run: |
50+
where.exe makensis
51+
where.exe 7z
52+
where.exe grep
53+
- name: Build installer
54+
run: pnpm -C cli exec oclif ${{ matrix.command }}
55+
- name: Upload installer artifact
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: ${{ matrix.artifact_name }}
59+
path: ${{ matrix.artifact_path }}
60+
retention-days: ${{ inputs.retention-days }}
61+
62+
package-tarballs:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: pnpm/action-setup@v4
67+
- uses: actions/setup-node@v4
68+
with:
69+
node-version-file: '.nvmrc'
70+
cache: 'pnpm'
71+
- run: pnpm install --frozen-lockfile
72+
- run: pnpm run build
73+
- name: Install 7-zip for packaging
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get install -y p7zip-full
77+
- name: Build tarballs
78+
run: pnpm -C cli exec oclif pack tarballs
79+
- name: Upload tarball artifacts
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: tarballs
83+
path: |
84+
cli/dist/**/*.tar.gz
85+
cli/dist/**/*.tar.xz
86+
retention-days: ${{ inputs.retention-days }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Manually Build CLI Installers for Testing
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
retention-days:
7+
description: 'Number of days to retain uploaded artifacts'
8+
type: number
9+
default: 7
10+
11+
jobs:
12+
build-artifacts:
13+
uses: ./.github/workflows/buildArtifacts.yml
14+
with:
15+
retention-days: ${{ inputs.retention-days || 7 }}

.github/workflows/onPushToMain.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/onRelease.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: publish on release
1+
name: Add CLI Installers to GitHub Release
22

33
env:
44
# Increase heap to keep Nitro/Vite SSR builds (editor) from OOMing while treeshaking.
@@ -8,19 +8,32 @@ on:
88
release:
99
types: [released]
1010

11+
permissions:
12+
contents: write
13+
1114
jobs:
12-
publish:
15+
build-artifacts:
16+
if: startsWith(github.event.release.tag_name, 'powersync@')
17+
uses: ./.github/workflows/buildArtifacts.yml
18+
with:
19+
retention-days: 1
20+
21+
publish-release-assets:
22+
needs: [build-artifacts]
1323
runs-on: ubuntu-latest
1424
steps:
15-
- uses: actions/checkout@v4
16-
- uses: pnpm/action-setup@v4
17-
- uses: actions/setup-node@v4
25+
- uses: actions/download-artifact@v4
1826
with:
19-
node-version-file: '.nvmrc'
20-
cache: 'pnpm'
21-
- run: pnpm install --frozen-lockfile
22-
- run: pnpm run build
23-
# - name: Publish @powersync/cli to npm
24-
# run: pnpm publish -- --no-git-checks --access public
25-
# env:
26-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
27+
path: release-assets
28+
- name: Upload assets to GitHub Release
29+
env:
30+
GH_TOKEN: ${{ github.token }}
31+
GH_REPO: ${{ github.repository }}
32+
run: |
33+
tag="${{ github.event.release.tag_name }}"
34+
files=$(find release-assets -type f \( -name "*.pkg" -o -name "*.exe" -o -name "*.deb" -o -name "*.tar.gz" -o -name "*.tar.xz" \))
35+
if [ -z "$files" ]; then
36+
echo "Error: No artifacts found to upload"
37+
exit 1
38+
fi
39+
gh release upload "$tag" $files --clobber

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch: # For dev publishing
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
permissions:
12+
id-token: write # Required for OIDC / trusted publishing
13+
contents: write # Required for changesets pushing commits
14+
pull-requests: write # Required for changesets creating PRs
15+
16+
jobs:
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout Repo
22+
uses: actions/checkout@v6
23+
- name: Enable Corepack
24+
run: corepack enable
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version-file: '.nvmrc'
29+
cache: pnpm
30+
- name: Update npm
31+
run: |
32+
npm install -g npm@latest
33+
npm --version
34+
- name: Install dependencies
35+
run: pnpm install
36+
37+
- name: Create Release Pull Request or Publish to npm
38+
id: changesets
39+
uses: changesets/action@v1
40+
if: ${{ github.event_name == 'push' }}
41+
with:
42+
# Update the monorepo lockfile after versioning
43+
version: pnpm changeset:version
44+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
45+
publish: pnpm release
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Dev publish
50+
if: ${{ github.event_name == 'workflow_dispatch' }}
51+
run: |
52+
pnpm build:packages
53+
pnpm changeset version --no-git-tag --snapshot dev
54+
pnpm changeset publish --tag dev
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: tests
1+
name: Unit Tests
22

33
env:
44
# Increase heap to keep Nitro/Vite SSR builds (editor) from OOMing while treeshaking.

0 commit comments

Comments
 (0)