Skip to content

Commit 79fa397

Browse files
committed
Here it comes...
0 parents  commit 79fa397

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
root = true
2+
[*]
3+
end_of_line = lf

action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Scratch Addons"
2+
author: "apple502j"
3+
description: "Packs Scratch Addons extension."
4+
inputs:
5+
ENVIRONMENT:
6+
description: 'Environment'
7+
required: true
8+
runs:
9+
using: "composite"
10+
steps:
11+
- run: bash $GITHUB_ACTION_PATH/scripts/pack.sh
12+
shell: bash
13+
name: "Pack extension"

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "packer-script",
3+
"version": "1.0.0",
4+
"description": "Packs Scratch Addons.",
5+
"main": "index.js",
6+
"scripts": {},
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/ScratchAddons/packer-script.git"
10+
},
11+
"author": "apple502j",
12+
"license": "GPL-3.0-or-later",
13+
"bugs": {
14+
"url": "https://github.com/ScratchAddons/packer-script/issues"
15+
},
16+
"homepage": "https://github.com/ScratchAddons/packer-script#readme",
17+
"private": true,
18+
"type": "module"
19+
}

scripts/manifest.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import fs from "fs/promises";
2+
import path from "path";
3+
4+
const GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE;
5+
const {default: generate} = await import(path.join(GITHUB_WORKSPACE, ".github/gen-manifest.js"));
6+
7+
const ENVIRONMENT = process.env.ENVIRONMENT;
8+
9+
const MANIFEST_PATH = path.join(GITHUB_WORKSPACE, "manifest.json");
10+
11+
await fs.copyFile(MANIFEST_PATH, path.join(GITHUB_WORKSPACE, ".manifest.json.bak"));
12+
13+
const manifestFile = await fs.readFile(MANIFEST_PATH, "utf8");
14+
const manifest = generate(ENVIRONMENT, JSON.parse(manifestFile));
15+
16+
await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest), "utf8");

scripts/pack.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
cd $GITHUB_WORKSPACE
3+
4+
export ENVIRONMENT=$INPUT_ENVIRONMENT
5+
6+
echo $(printf "Packing build for %s" $ENVIRONMENT)
7+
8+
node $GITHUB_ACTION_PATH/scripts/manifest.js
9+
mkdir $GITHUB_WORKSPACE/.dist 2>/dev/null
10+
11+
VERSION_NAME=$(cat $GITHUB_WORKSPACE/manifest.json | jq ".version_name" | sed "s/[.-]/_/g;s/prerelease/pre/")
12+
FILENAME=$(printf "ScratchAddons-%s-%s.zip" $VERSION_NAME $ENVIRONMENT)
13+
14+
git archive --format=zip -o $GITHUB_WORKSPACE/.dist/$FILENAME HEAD
15+
rm $GITHUB_WORKSPACE/manifest.json
16+
mv $GITHUB_WORKSPACE/.manifest.json.bak $GITHUB_WORKSPACE/manifest.json
17+
18+
echo $(printf "Packed as %s" $FILENAME)

0 commit comments

Comments
 (0)