Skip to content

Commit

Permalink
feat: build release script and action
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcWadai committed Jan 28, 2025
1 parent 18a64d8 commit 8f09eb8
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 3 deletions.
Empty file added .github/workflows/publish.yml
Empty file.
53 changes: 53 additions & 0 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "test-on-pr"

on: [pull_request]

# This workflow will build your tauri app without uploading it anywhere.

jobs:
test-tauri:
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
args: ""
- platform: "windows-latest"
args: ""

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.

- name: install frontend dependencies
run: yarn install # change this to npm, pnpm or bun depending on which one you use.

# If tagName and releaseId are omitted tauri-action will only build the app and won't try to upload any assets.
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: ${{ matrix.args }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dist
dist-ssr
*.local

deploys
# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
3 changes: 0 additions & 3 deletions .vscode/extensions.json

This file was deleted.

Empty file added scripts/check-deploys.ts
Empty file.
74 changes: 74 additions & 0 deletions scripts/fetch-package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env -S npx tsx --resolveJsonModule

import * as path from "node:path";
import { createWriteStream, promises as fs } from "node:fs";
import { promises as stream } from "node:stream";

import tchapConfigFile from "../tchap_config.json";

const PACKAGE_URL_PREFIX = "https://github.com/element-hq/element-web/releases/download/"

async function downloadToFile(url: string, filename: string): Promise<void> {
console.log("Downloading " + url + "...");

try {
const resp = await fetch(url);
if (!resp.ok) throw new Error(`unexpected response ${resp.statusText}`);
if (!resp.body) throw new Error(`unexpected response has no body ${resp.statusText}`);
await stream.pipeline(resp.body, createWriteStream(filename));
} catch (e) {
console.error(e);
try {
await fs.unlink(filename);
} catch {}
throw e;
}
}

function cleanFolder(directory) {
fs.readdir(directory, (err, files) => {
if (err) throw err;

for (const file of files) {
fs.unlink(path.join(directory, file), (err) => {
if (err) throw err;
});
}
});
}

async function main(): Promise<number | undefined> {
let pkgDir = "src";
let targetVersion: string | undefined = tchapConfigFile!["tchap-web_version"];
let filename: string | undefined = tchapConfigFile!["tchap-web_archive_name"];
let url: string | undefined;


filename = `tchap-${targetVersion}.tar.gz`;
url = PACKAGE_URL_PREFIX + targetVersion + "/" + filename;

// clean up src folder firstc
try {
cleanFolder(pkgDir);
console.log(pkgDir + "cleaned");
} catch {}

const outPath = path.join(pkgDir, filename);
try {
await downloadToFile(url, outPath);
} catch (e) {
console.log("Failed to download " + url, e);
return 1;
}

console.log("Done!");
}

main()
.then((ret) => {
process.exit(ret);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
5 changes: 5 additions & 0 deletions tchap_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"release_version": "0.0.0",
"tchap-web_version": "4.12.1",
"tchap-web_archive_name": "tchap-4.12.1-prod-20250113.tar.gz"
}

0 comments on commit 8f09eb8

Please sign in to comment.