Skip to content

Commit

Permalink
try converting packer to bash
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBrax committed Nov 7, 2023
1 parent 080407a commit 3d14e4f
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 37 deletions.
3 changes: 2 additions & 1 deletion pack-dev.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
node ./pack.mjs --prerelease
#node ./pack.mjs --prerelease
./packer-main.sh --prerelease
77 changes: 42 additions & 35 deletions pack.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import util from "node:util";
import fs from "node:fs";
import exec from "node:child_process";
const client_version = JSON.parse(fs.readFileSync("./client-vue/package.json")).version;
const server_version = JSON.parse(fs.readFileSync("./server/package.json")).version;
const dumper_version = JSON.parse(fs.readFileSync("./twitch-chat-dumper/package.json")).version;
const vodchat_version = JSON.parse(fs.readFileSync("./twitch-vod-chat/package.json")).version;
import fs from "node:fs";
import util from "node:util";
const client_version = JSON.parse(
fs.readFileSync("./client-vue/package.json")
).version;
const server_version = JSON.parse(
fs.readFileSync("./server/package.json")
).version;
const dumper_version = JSON.parse(
fs.readFileSync("./twitch-chat-dumper/package.json")
).version;
const vodchat_version = JSON.parse(
fs.readFileSync("./twitch-vod-chat/package.json")
).version;

const pexec = util.promisify(exec.exec);

Expand All @@ -16,49 +24,51 @@ console.log(`twitch-vod-chat version: ${vodchat_version}`);
const prerelease = process.argv.includes("--prerelease");

// simple iso date string without time
const date_string = new Date().toISOString().split('T')[0];
const date_string = new Date().toISOString().split("T")[0];

const release_name = `LiveStreamDVR-${date_string}-c${client_version}-s${server_version}-d${dumper_version}-v${vodchat_version}${prerelease ? "-alpha" : ""}`;
const release_name = `LiveStreamDVR-${date_string}-c${client_version}-s${server_version}-d${dumper_version}-v${vodchat_version}${
prerelease ? "-alpha" : ""
}`;

if (fs.existsSync(`./release/${release_name}.zip`)) {
fs.unlinkSync(`./release/${release_name}.zip`);
fs.unlinkSync(`./release/${release_name}.zip`);
}

console.log(`Release name: ${release_name}`);
console.log("Building...");

// build twitch-vod-chat
await pexec('cd twitch-vod-chat && yarn install && yarn run buildlib');
await pexec("cd twitch-vod-chat && yarn install && yarn run buildlib");
console.log("twitch-vod-chat built");

// build client
await pexec('cd client-vue && yarn install && yarn run build');
await pexec("cd client-vue && yarn install && yarn run build");
console.log("Client built");

// build server
await pexec('cd server && yarn install && yarn run build');
await pexec("cd server && yarn install && yarn run build");
console.log("Server built");

// build twitch-chat-dumper
await pexec('cd twitch-chat-dumper && yarn install && yarn run build');
await pexec("cd twitch-chat-dumper && yarn install && yarn run build");
console.log("twitch-chat-dumper built");

// package files
await pexec(
`7za a -tzip -xr!node_modules ./release/${release_name}.zip ` +
`client-vue/dist ` +
`7za a -tzip -xr!node_modules ./release/${release_name}.zip ` +
`client-vue/dist ` +
`client-vue/package.json ` +
`server/build ` +
`server/build ` +
`server/package.json ` +
`server/tsconfig.json ` +
`server/tsconfig.json ` +
`twitch-chat-dumper/build ` +
// `twitch-vod-chat/dist ` +
`start.bat ` +
`start.sh ` +
`requirements.txt ` +
`requirements.txt ` +
`binaries.txt ` +
`Pipfile ` +
`Pipfile.lock ` +
`Pipfile ` +
`Pipfile.lock ` +
`README.md ` +
`LICENSE `
);
Expand All @@ -67,24 +77,21 @@ console.log("Files packaged");

// output metadata
fs.writeFileSync(
`./release/${release_name}.json`,
JSON.stringify({
client_version,
server_version,
dumper_version,
vodchat_version,
release_name
})
`./release/${release_name}.json`,
JSON.stringify({
client_version,
server_version,
dumper_version,
vodchat_version,
release_name,
})
);

fs.writeFileSync(
`./release_name.txt`,
release_name
);
fs.writeFileSync(`./release_name.txt`, release_name);

fs.writeFileSync(
`./release_notes.md`,
`This release was created automatically by the build script.\n\n` +
`./release_notes.md`,
`This release was created automatically by the build script.\n\n` +
`It includes the following versions:\n\n` +
`* Client: ${client_version}\n` +
`* Server: ${server_version}\n` +
Expand All @@ -98,7 +105,7 @@ console.log("Metadata written");

// upload to github
await pexec(
`gh release create ${release_name} ` +
`gh release create ${release_name} ` +
`./release/${release_name}.zip ` +
`-t "${release_name}" ` + // title
// `-n "${release_name}" ` + // description
Expand Down
3 changes: 2 additions & 1 deletion pack.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
node ./pack.mjs
# node ./pack.mjs
./packer-main.sh
78 changes: 78 additions & 0 deletions packer-main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
set set -euxo pipefail # exit with nonzero exit code if anything fails

client_version=$(cat ./client-vue/package.json | jq -r '.version')
server_version=$(cat ./server/package.json | jq -r '.version')
dumper_version=$(cat ./twitch-chat-dumper/package.json | jq -r '.version')
vodchat_version=$(cat ./twitch-vod-chat/package.json | jq -r '.version')

echo "Client version: $client_version"
echo "Server version: $server_version"
echo "twitch-chat-dumper version: $dumper_version"
echo "twitch-vod-chat version: $vodchat_version"

prerelease=false
if [[ "$@" == *"--prerelease"* ]]; then
prerelease=true
fi

# simple iso date string without time
date_string=$(date -u +"%Y-%m-%d")

release_name="LiveStreamDVR-${date_string}-c${client_version}-s${server_version}-d${dumper_version}-v${vodchat_version}"
if [ "$prerelease" = true ]; then
release_name="${release_name}-alpha"
fi

if [ -f "./release/${release_name}.zip" ]; then
rm "./release/${release_name}.zip"
fi

echo "Release name: $release_name"
echo "Building..."

# build twitch-vod-chat
cd twitch-vod-chat && yarn install && yarn run buildlib && cd ..

echo "twitch-vod-chat built"

# build client
cd client-vue && yarn install && yarn run build && cd ..

echo "Client built"

# build server
cd server && yarn install && yarn run build && cd ..

echo "Server built"

# build twitch-chat-dumper
cd twitch-chat-dumper && yarn install && yarn run build && cd ..

echo "twitch-chat-dumper built"

# package files
7za a -tzip -xr!node_modules "./release/${release_name}.zip" \
"client-vue/dist" \
"client-vue/package.json" \
"server/build" \
"server/package.json" \
"server/tsconfig.json" \
"twitch-chat-dumper/build" \
"start.bat" \
"start.sh" \
"requirements.txt" \
"binaries.txt" \
"Pipfile" \
"Pipfile.lock" \
"README.md" \
"LICENSE"

echo "Files packaged"

# output metadata
echo "{\"client_version\":\"$client_version\",\"server_version\":\"$server_version\",\"dumper_version\":\"$dumper_version\",\"vodchat_version\":\"$vodchat_version\",\"release_name\":\"$release_name\"}" > "./release/${release_name}.json"

echo "$release_name" > "./release_name.txt"

echo -e "This release was created automatically by the build script.\n\nIt includes the following versions:\n\n* Client: $client_version\n* Server: $server_version\n* twitch-chat-dumper: $dumper_version\n* twitch-vod-chat: $vodchat_version\n\n## Changelog\n\n" > "./release_notes.md"

0 comments on commit 3d14e4f

Please sign in to comment.