Skip to content

Commit

Permalink
Package & distribute frontend bundle when doing releases for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenVolkoff committed May 21, 2024
1 parent 96a45ee commit c846a7e
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 153 deletions.
39 changes: 21 additions & 18 deletions .github/actions/publish-artifacts/dist/index.js

Large diffs are not rendered by default.

26 changes: 19 additions & 7 deletions .github/actions/publish-artifacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,32 @@ const BUNDLE_DIR = `target/${TARGET}/${PROFILE}/bundle`;
const ARTIFACTS_DIR = '.artifacts';
const ARTIFACT_BASE = `Spacedrive-${OS}-${ARCH}`;
const UPDATER_ARTIFACT_NAME = `Spacedrive-Updater-${OS}-${ARCH}`;
const FRONTEND_ARCHIVE_NAME = `Spacedrive-frontend-${OS}-${ARCH}`;

async function globFiles(pattern: string) {
const globber = await glob.create(pattern);
return await globber.glob();
}

async function uploadFrontend() {
const files = await globFiles(`apps/desktop/dist.{tar.gz,tar.xz,zip}`);
const file = files[0];
if (!file) {
console.error(`Frontend archive not found`);
return;
}

await client.uploadArtifact(FRONTEND_ARCHIVE_NAME, [file], 'apps/desktop');
}

async function uploadUpdater(updater: BuildTarget['updater']) {
if (!updater) return;
const { bundle, bundleExt, archiveExt } = updater;
const fullExt = `${bundleExt}.${archiveExt}`;
const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${fullExt}*`);

const updaterPath = files.find((file) => file.endsWith(fullExt));
if (!updaterPath) return console.error(`Updater path not found. Files: ${files}`);
if (!updaterPath) throw new Error(`Updater path not found. Files: ${files}`);

const artifactPath = `${ARTIFACTS_DIR}/${UPDATER_ARTIFACT_NAME}.${archiveExt}`;

Expand All @@ -76,7 +88,7 @@ async function uploadStandalone({ bundle, ext }: TargetConfig) {
const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${ext}*`);

const standalonePath = files.find((file) => file.endsWith(ext));
if (!standalonePath) return console.error(`Standalone path not found. Files: ${files}`);
if (!standalonePath) throw new Error(`Standalone path not found. Files: ${files}`);

const artifactName = `${ARTIFACT_BASE}.${ext}`;
const artifactPath = `${ARTIFACTS_DIR}/${artifactName}`;
Expand All @@ -90,10 +102,10 @@ async function run() {

const { updater, standalone } = OS_TARGETS[OS];

await uploadUpdater(updater);

for (const config of standalone) {
await uploadStandalone(config);
}
await Promise.all([
uploadUpdater(updater),
uploadFrontend(),
...standalone.map((config) => uploadStandalone(config))
]);
}
run();
2 changes: 1 addition & 1 deletion .github/actions/publish-artifacts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint . --cache"
},
"dependencies": {
"@actions/artifact": "^2.1.3",
"@actions/artifact": "^2.1.7",
"@actions/core": "^1.10.1",
"@actions/glob": "^0.4.0",
"@actions/io": "^1.1.3"
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Release

on:
pull_request:
paths:
- '.github/workflows/release.yml'
workflow_dispatch:
# NOTE: For Linux builds, we can only build with Ubuntu. It should be the oldest base system we intend to support. See PR-759 & https://tauri.app/v1/guides/building/linux for reference.

# From: https://github.com/rust-lang/rust-analyzer/blob/master/.github/workflows/release.yaml#L13-L21
env:
Expand Down Expand Up @@ -112,6 +114,12 @@ jobs:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

- name: Package frontend
if: ${{ runner.os == 'Linux' }}
run: |
set -eux
XZ_OPT='-T0 -7' tar -cJf apps/desktop/dist.tar.xz -C apps/desktop/dist .
- name: Publish Artifacts
uses: ./.github/actions/publish-artifacts
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Server release
on:
release:
types: [published]
pull_request:
paths:
- '.github/workflows/server.yml'
workflow_dispatch:

jobs:
Expand Down
Loading

0 comments on commit c846a7e

Please sign in to comment.