-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (88 loc) · 3.11 KB
/
release.yml
File metadata and controls
99 lines (88 loc) · 3.11 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
name: Release
env:
# Increase heap to keep Nitro/Vite SSR builds (editor) from OOMing while treeshaking.
NODE_OPTIONS: --max-old-space-size=4096
on:
push:
branches:
- main
workflow_dispatch: # For dev publishing
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write # Required for OIDC / trusted publishing
contents: write # Required for changesets pushing commits
pull-requests: write # Required for changesets creating PRs
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
release-tag: ${{ steps.release-tag.outputs.tag }}
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: pnpm
- name: Update npm
run: |
npm install -g npm@latest
npm --version
- name: Install dependencies
run: pnpm install
- name: Build packages
run: pnpm build:packages
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
if: ${{ github.event_name == 'push' }}
with:
# Update the monorepo lockfile after versioning
version: pnpm changeset:version
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve release tag
id: release-tag
if: ${{ steps.changesets.outputs.published == 'true' }}
run: echo "tag=powersync@$(jq -r '.version' cli/package.json)" >> "$GITHUB_OUTPUT"
- name: Dev publish
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
pnpm build:packages
pnpm changeset version --no-git-tag --snapshot dev
pnpm changeset publish --tag dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-artifacts:
needs: [release]
# Changesets links all package versions, so any publish means the powersync package was published.
if: needs.release.outputs.published == 'true'
uses: ./.github/workflows/buildArtifacts.yml
with:
retention-days: 1
publish-release-assets:
needs: [release, build-artifacts]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: release-assets
- name: Upload assets to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
tag="${{ needs.release.outputs.release-tag }}"
files=$(find release-assets -type f \( -name "*.pkg" -o -name "*.exe" -o -name "*.deb" -o -name "*.tar.gz" -o -name "*.tar.xz" \))
if [ -z "$files" ]; then
echo "Error: No artifacts found to upload"
exit 1
fi
gh release upload "$tag" $files --clobber