Skip to content

Commit 18601ee

Browse files
authored
Merge pull request #368 from FilenCloudDienste/dev/use-bun
Use Bun
2 parents 3efcdd2 + b08409e commit 18601ee

41 files changed

Lines changed: 1565 additions & 9075 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-publish.yml

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,50 @@ on:
66

77
jobs:
88
build-and-publish-binaries:
9-
name: Build binaries (${{ matrix.target }})
9+
name: Build binaries (${{ matrix.name }})
1010
strategy:
1111
matrix:
1212
include:
13-
- os: windows-latest
14-
target: win
15-
- os: ubuntu-latest
16-
target: linux
17-
- os: macos-latest
18-
target: macos
13+
- name: win-x64
14+
target: windows-x64 --windows-icon=.github/workflows/filen-icon.ico
15+
os: windows-11-arm # see note below
16+
- name: linux-x64
17+
target: linux-x64
18+
os: ubuntu-latest
19+
- name: linux-arm64
20+
target: linux-arm64
21+
os: ubuntu-24.04-arm
22+
- name: macos-x64
23+
target: macos-x64
24+
os: macos-latest
25+
- name: macos-arm64
26+
target: macos-arm64
27+
os: macos-latest
1928
runs-on: ${{ matrix.os }}
2029
permissions:
2130
contents: write
2231
steps:
2332
- name: Checkout
2433
uses: actions/checkout@v3
25-
- name: Inject version
26-
uses: richardrigutins/replace-in-files@v2
34+
- name: Install bun
35+
if: ${{ matrix.os != 'windows-11-arm' }}
36+
uses: oven-sh/setup-bun@v2
37+
# Installing Bun on Windows is a bit different:
38+
# Bun doesn't support Windows ARM64 (yet?), so we're installing the x64 version, which can be run on Windows arm64 machines via emulation.
39+
# However, it seems that the x64 binary built on x64 can't be run on arm64, so we need to build the x64 binary on an arm64 machine.
40+
# The oven-sh/setup-bun action doesn't support installing x64 Bun on arm64, so we do it manually using the install script (and then add it to the PATH).
41+
- name: Install bun (Windows)
42+
if: ${{ matrix.os == 'windows-11-arm' }}
43+
run: powershell -c "irm bun.sh/install.ps1|iex"
44+
- name: Add bun to path (Windows)
45+
if: ${{ matrix.os == 'windows-11-arm' }}
46+
uses: actions/github-script@v7
2747
with:
28-
files: "package.json"
29-
search-text: "\"version\": \"0.0.0\""
30-
replacement-text: "\"version\": \"${{ github.event.release.tag_name }}\""
31-
- name: Setup Node
32-
uses: actions/setup-node@v4
33-
with:
34-
node-version-file: .node-version
35-
- run: npm ci
36-
- run: npm run package-${{ matrix.target }}
48+
script: core.addPath('C:\\Users\\runneradmin\\.bun\\bin');
49+
- run: bun install
50+
- run: bun run compile --target=bun-${{ matrix.target }} --define "FILEN_CLI_VERSION=${{ github.event.release.tag_name }}" --outfile dist/filen-cli-${{ github.event.release.tag_name }}-${{ matrix.name }}
3751
- name: Codesign and notarize on macOS
38-
if: ${{ matrix.target == 'macos' }}
52+
if: ${{ matrix.os == 'macos-latest' }}
3953
env:
4054
APPLE_DEVELOPER_ID_CERT: ${{ secrets.APPLE_DEVELOPER_ID_CERT }}
4155
APPLE_DEVELOPER_ID_CERT_PASS: ${{ secrets.APPLE_DEVELOPER_ID_CERT_PASS }}
@@ -53,21 +67,27 @@ jobs:
5367
security unlock-keychain -p actions ~/Library/Keychains/build.keychain
5468
security set-key-partition-list -S apple-tool:,apple: -s -k actions ~/Library/Keychains/build.keychain
5569
# codesign
56-
codesign --sign "Developer ID Application: Filen Cloud Dienste UG (haftungsbeschraenkt)" --options runtime --force --deep --keychain ~/Library/Keychains/build.keychain --entitlements=../.github/workflows/entitlements.plist filen-cli-macos-x64 filen-cli-macos-arm64
70+
codesign --sign "Developer ID Application: Filen Cloud Dienste UG (haftungsbeschraenkt)" --options runtime --force --deep --keychain ~/Library/Keychains/build.keychain --entitlements=../.github/workflows/entitlements.plist filen-cli-${{ github.event.release.tag_name }}-${{ matrix.name }}
5771
# notarize
58-
zip filen-cli-macos.zip filen-cli-macos-x64 filen-cli-macos-arm64
72+
zip filen-cli-macos.zip filen-cli-${{ github.event.release.tag_name }}-${{ matrix.name }}
5973
xcrun notarytool submit filen-cli-macos.zip --apple-id $APPLE_NOTARIZE_ID --password $APPLE_NOTARIZE_PASS --team-id $APPLE_NOTARIZE_TEAM_ID --output-format json --wait 2>&1 | tee notarization_info.json
6074
id=$(cat notarization_info.json | jq -r '.id')
6175
xcrun notarytool log $id --apple-id $APPLE_NOTARIZE_ID --password $APPLE_NOTARIZE_PASS --team-id $APPLE_NOTARIZE_TEAM_ID
6276
# cleanup certificate
6377
security delete-keychain build.keychain
6478
rm -f certificate.p12
65-
- name: Rename binaries to include release number
66-
run: node -e "['win-x64.exe', 'win-arm64.exe', 'linux-x64', 'linux-arm64', 'macos-x64', 'macos-arm64'].forEach(suffix => { if (fs.existsSync('dist/filen-cli-'+suffix)) { fs.renameSync('dist/filen-cli-'+suffix, 'dist/filen-cli-${{ github.event.release.tag_name }}-'+suffix) } })"
79+
rm filen-cli-macos.zip
80+
- name: Execute binary
81+
if: ${{ matrix.target != 'macos-x64' }}
82+
run: dist/filen-cli-${{ github.event.release.tag_name }}-${{ matrix.name }} --help
83+
- name: Copy win-x64 binary as win-arm64 binary
84+
# so the updater won't be confused
85+
if: ${{ matrix.os == 'windows-11-arm' }}
86+
run: cp dist/filen-cli-${{ github.event.release.tag_name }}-win-x64.exe dist/filen-cli-${{ github.event.release.tag_name }}-win-arm64.exe
6787
- name: Attach binaries to release
6888
uses: softprops/action-gh-release@v2
6989
with:
70-
files: dist/filen-cli-${{ github.event.release.tag_name }}-*
90+
files: dist/filen-cli-*
7191

7292
build-and-publish-npm:
7393
name: Build and publish to npm
@@ -82,29 +102,23 @@ jobs:
82102
files: "package.json"
83103
search-text: "\"version\": \"0.0.0\""
84104
replacement-text: "\"version\": \"${{ github.event.release.tag_name }}\""
105+
- name: Install bun
106+
uses: oven-sh/setup-bun@v2
107+
- run: bun install
108+
- run: bun build --target=node --sourcemap --define VERSION="${{ github.event.release.tag_name }}" --define IS_RUNNING_AS_NPM_PACKAGE=true src/index.ts --outdir build --external "@jupiterpi/node-keyring" --external "@parcel/watcher"
85109
- name: Setup Node
86110
uses: actions/setup-node@v4
87-
with:
88-
node-version-file: .node-version
89-
registry-url: "https://registry.npmjs.org"
90-
- run: npm ci
91-
- run: npm publish --access public # includes build
111+
- run: npm publish --access public
92112
env:
93-
FILEN_IS_NPM_PACKAGE: true
94113
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
95114

96115
build-and-publish-docker:
97116
name: Build Docker image
98117
runs-on: ubuntu-latest
99118
if: ${{ github.event.release.prerelease == false }}
100119
steps:
101-
- uses: actions/checkout@v3
102-
- name: Inject version
103-
uses: richardrigutins/replace-in-files@v2
104-
with:
105-
files: "package.json"
106-
search-text: "\"version\": \"0.0.0\""
107-
replacement-text: "\"version\": \"${{ github.event.release.tag_name }}\""
120+
- name: Checkout
121+
uses: actions/checkout@v3
108122
- name: Log in to Docker Hub
109123
uses: docker/login-action@v3
110124
with:
@@ -139,13 +153,11 @@ jobs:
139153
files: "package.json"
140154
search-text: "\"version\": \"0.0.0\""
141155
replacement-text: "\"version\": \"${{ github.event.release.tag_name }}\""
156+
- name: Install bun
157+
uses: oven-sh/setup-bun@v2
158+
- run: bun install
142159
- name: Setup Node
143160
uses: actions/setup-node@v4
144-
with:
145-
node-version-file: .node-version
146-
- run: npm ci
147-
- name: Build filen-cli
148-
run: npm run build
149161
- name: Build docs
150162
run: chmod +x build-docs.sh && ./build-docs.sh && mv filen-cli-docs.html filen-cli-${{ github.event.release.tag_name }}-docs.html
151163
- name: Attach HTML file to release

.github/workflows/eslint.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ jobs:
2525
steps:
2626
- name: Checkout
2727
uses: actions/checkout@v3
28-
- name: Setup Node
29-
uses: actions/setup-node@v4
30-
with:
31-
node-version-file: .node-version
32-
- run: npm ci
33-
- run: npm run lint-ci
28+
- name: Install bun
29+
uses: oven-sh/setup-bun@v2
30+
- run: bun install
31+
- run: bun run lint-ci
3432
continue-on-error: true
3533
- name: Upload analysis results to GitHub
3634
uses: github/codeql-action/upload-sarif@v3
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
name: Run Vitest tests
1+
name: Run tests
22

33
on:
44
push:
55
pull_request:
66
types: [opened, synchronize, reopened]
77

88
jobs:
9-
vitest:
9+
test:
1010
runs-on: ubuntu-latest
1111
env:
1212
FILEN_CLI_TESTING_EMAIL: ${{ secrets.V2_TEST_ACC_EMAIL }}
1313
FILEN_CLI_TESTING_PASSWORD: ${{ secrets.V2_TEST_ACC_PASS }}
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v3
17-
- name: Setup Node
18-
uses: actions/setup-node@v4
19-
with:
20-
node-version-file: .node-version
21-
- run: npm ci
22-
- name: Run Vitest
23-
run: npm run test
17+
- name: Install bun
18+
uses: oven-sh/setup-bun@v2
19+
- run: bun install
20+
- run: bun run test

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
node_modules/**/*
2-
build
3-
dist
42
.DS_Store
53
tmp
64
.idea
75
.env
8-
testing
6+
testing
7+
filen-cli.exe
8+
filen-cli
9+
build

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!build/**

Dockerfile

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
FROM node:23-alpine AS build
1+
FROM oven/bun:1 AS base
22
WORKDIR /filen-cli
3+
4+
FROM base AS install
5+
6+
RUN mkdir -p /temp/dev
7+
COPY package.json bun.lock /temp/dev/
8+
COPY patches/*.patch /temp/dev/patches/
9+
RUN cd /temp/dev && bun install --frozen-lockfile
10+
11+
RUN mkdir -p /temp/prod
12+
COPY package.json bun.lock /temp/prod/
13+
COPY patches/*.patch /temp/prod/patches/
14+
RUN cd /temp/prod && bun install --frozen-lockfile --production
15+
16+
FROM base AS prerelease
17+
COPY --from=install /temp/dev/node_modules node_modules
318
COPY . .
4-
ENV FILEN_IS_CONTAINER=true
5-
RUN npm ci && npm run build
19+
RUN bun build --target=bun --sourcemap --define IS_RUNNING_AS_CONTAINER=true src/index.ts --outdir build
620

7-
FROM node:23-alpine
8-
WORKDIR /filen-cli
9-
COPY --from=build /filen-cli/dist/bundle.js /filen-cli/filen.js
10-
ARG TARGETARCH
11-
RUN if [ "$TARGETARCH" = "amd64" ] ; then npm install @parcel/watcher-linux-x64-musl ; else npm install @parcel/watcher-linux-arm64-musl ; fi
21+
FROM base AS release
22+
COPY --from=install /temp/prod/node_modules node_modules
23+
COPY --from=prerelease /filen-cli/build build
24+
COPY --from=prerelease /filen-cli/package.json package.json
25+
26+
USER bun
1227
EXPOSE 80
13-
ENTRYPOINT ["node", "filen.js"]
28+
ENTRYPOINT [ "bun", "run", "build/index.js" ]

build-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
node build/index.js internal-export-docs-json
3+
bun start internal-export-docs-json
44

55
cp ./filen-cli-docs.json ./filen-cli-docs/src/filen-cli-docs.json
66

0 commit comments

Comments
 (0)