Skip to content

Commit 22c8da0

Browse files
committed
chore: Cleanup CI
1 parent 6befbf4 commit 22c8da0

File tree

2 files changed

+70
-36
lines changed

2 files changed

+70
-36
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,50 +75,16 @@ jobs:
7575
NODE_ENV: production
7676

7777
- name: Copy files to dist
78-
id: copy-files-to-dist
7978
run: |
80-
mkdir -p dist
81-
cp "plugin.json" dist/plugin.json 2>/dev/null || { echo "::error::plugin.json was not found. It is required for plugins to have."; exit 1; }
82-
cp "requirements.txt" dist/requirements.txt 2>/dev/null || echo "::warning::requirements.txt not found, skipping."
83-
cp "README.md" dist/README.md 2>/dev/null || echo "::warning::README.md not found, skipping."
84-
cp "README" dist/README 2>/dev/null || echo "::warning::README not found, skipping."
85-
86-
backend=$(jq -r '.backend' plugin.json)
87-
if [ "$backend" != "null" ]; then
88-
cp -r "$backend" ./dist/"$backend"
89-
fi
90-
91-
include=$(jq -r '.include // empty' plugin.json)
92-
if [ -n "$include" ]; then
93-
for file in $include; do
94-
cp -r "$file" ./dist/"$file"
95-
done
96-
fi
97-
98-
echo "::notice::Computing plugin metadata..."
99-
echo "{\"commit\": \"$(git rev-parse HEAD)\", \"id\": \"$(git rev-list --max-parents=0 HEAD)\"}" > dist/metadata.json
100-
101-
id=$(jq -r '.id' dist/metadata.json)
102-
echo "::set-output name=id::$id" # Set the id as an output variable
103-
104-
cd dist
105-
zip -r "$id.zip" .
106-
107-
echo "::notice::Successfully built plugin."
108-
109-
# - name: Upload plugin
110-
# uses: actions/upload-artifact@v4
111-
# with:
112-
# name: ${{ steps.copy-files-to-dist.outputs.id }} # Correct reference here
113-
# path: dist/${{ steps.copy-files-to-dist.outputs.id }}.zip
79+
sudo node ./scripts/create-release.js
11480
11581
finalize:
11682
needs: process-plugin
11783
runs-on: ubuntu-latest
11884
if: ${{ always() }}
11985
steps:
12086
- name: List built plugins
121-
run: ls -l build/
87+
run: ls -R
12288

12389
- name: Run Semantic Release
12490
run: |

scripts/create-release.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { execSync } = require('child_process');
4+
5+
// Helper function to safely copy files
6+
function copyFile(src, dest) {
7+
try {
8+
fs.copyFileSync(src, dest);
9+
console.log(`Copied ${src} to ${dest}`);
10+
} catch (err) {
11+
console.warn(`::warning:: ${src} not found, skipping.`);
12+
}
13+
}
14+
15+
// Create 'dist' directory if it doesn't exist
16+
const distDir = path.join(__dirname, 'dist');
17+
if (!fs.existsSync(distDir)) {
18+
fs.mkdirSync(distDir, { recursive: true });
19+
}
20+
21+
// Copy the necessary files
22+
copyFile('plugin.json', path.join(distDir, 'plugin.json'));
23+
copyFile('requirements.txt', path.join(distDir, 'requirements.txt'));
24+
copyFile('README.md', path.join(distDir, 'README.md'));
25+
copyFile('README', path.join(distDir, 'README'));
26+
27+
// Read the plugin.json
28+
const pluginJson = JSON.parse(fs.readFileSync('plugin.json', 'utf-8'));
29+
30+
// Handle the backend field
31+
const backend = pluginJson.backend;
32+
if (backend !== null && backend) {
33+
const backendPath = path.join(__dirname, backend);
34+
if (fs.existsSync(backendPath)) {
35+
fs.cpSync(backendPath, path.join(distDir, backend), { recursive: true });
36+
console.log(`Copied backend: ${backend}`);
37+
}
38+
}
39+
40+
// Handle the include field
41+
const include = pluginJson.include || [];
42+
include.forEach(file => {
43+
const filePath = path.join(__dirname, file);
44+
if (fs.existsSync(filePath)) {
45+
fs.cpSync(filePath, path.join(distDir, file), { recursive: true });
46+
console.log(`Copied included file: ${file}`);
47+
}
48+
});
49+
50+
// Generate metadata
51+
const commit = execSync('git rev-parse HEAD').toString().trim();
52+
const id = execSync('git rev-list --max-parents=0 HEAD').toString().trim();
53+
const metadata = {
54+
commit,
55+
id,
56+
};
57+
58+
fs.writeFileSync(path.join(distDir, 'metadata.json'), JSON.stringify(metadata, null, 2));
59+
console.log('::notice::Computing plugin metadata...');
60+
61+
// Set the ID as an output variable (in GitHub Actions context, for example)
62+
console.log(`::set-output name=id::${id}`);
63+
64+
// Create the zip file using the 'zip' command
65+
const zipCommand = `zip -r ${path.join(distDir, `${id}.zip`)} .`;
66+
execSync(zipCommand, { cwd: distDir });
67+
68+
console.log(`::notice::Successfully built plugin: ${id}.zip`);

0 commit comments

Comments
 (0)