Skip to content

Commit

Permalink
ci: fix distribution tool
Browse files Browse the repository at this point in the history
  • Loading branch information
XeroxDev committed Feb 12, 2024
1 parent f9af51f commit 7441d63
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 33 deletions.
62 changes: 31 additions & 31 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,34 @@ jobs:
with:
target-branch: master

- name: Run build
run: npm run build

- name: Create distribution folder
run: |
mkdir fun.shiro.ytmd.sdPlugin
copy sdpi.css fun.shiro.ytmd.sdPlugin\
copy manifest.json fun.shiro.ytmd.sdPlugin\
copy property-inspector.html fun.shiro.ytmd.sdPlugin\
copy action.html fun.shiro.ytmd.sdPlugin\
copy bundle.js fun.shiro.ytmd.sdPlugin\
copy bundle-pi.js fun.shiro.ytmd.sdPlugin\
copy icons fun.shiro.ytmd.sdPlugin -Recurse
- name: Download Stream Deck Distribution Tool
uses: carlosperate/[email protected]
with:
file-url: https://developer.elgato.com/documentation/stream-deck/distributiontool/DistributionToolWindows.zip
file-name: distribution-tool.zip

- name: Unzip Stream Deck Distribution Tool
run: tar -xf .\distribution-tool.zip

- name: Validate plugin and build .streamDeckPlugin file
run: ./DistributionTool.exe -b -i fun.shiro.ytmd.sdPlugin -o ./

- name: Upload Release Artifact
if: ${{ steps.release.outputs.release_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ steps.release.outputs.tag_name }} ./fun.shiro.ytmd.streamDeckPlugin --clobber
# - name: Run build
# run: npm run build
#
# - name: Create distribution folder
# run: |
# mkdir fun.shiro.ytmd.sdPlugin
# copy sdpi.css fun.shiro.ytmd.sdPlugin\
# copy manifest.json fun.shiro.ytmd.sdPlugin\
# copy property-inspector.html fun.shiro.ytmd.sdPlugin\
# copy action.html fun.shiro.ytmd.sdPlugin\
# copy bundle.js fun.shiro.ytmd.sdPlugin\
# copy bundle-pi.js fun.shiro.ytmd.sdPlugin\
# copy icons fun.shiro.ytmd.sdPlugin -Recurse
#
# - name: Download Stream Deck Distribution Tool
# uses: carlosperate/[email protected]
# with:
# file-url: https://developer.elgato.com/documentation/stream-deck/distributiontool/DistributionToolWindows.zip
# file-name: distribution-tool.zip
#
# - name: Unzip Stream Deck Distribution Tool
# run: tar -xf .\distribution-tool.zip
#
# - name: Validate plugin and build .streamDeckPlugin file
# run: ./DistributionTool.exe -b -i fun.shiro.ytmd.sdPlugin -o ./
#
# - name: Upload Release Artifact
# if: ${{ steps.release.outputs.release_created }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: gh release upload ${{ steps.release.outputs.tag_name }} ./fun.shiro.ytmd.streamDeckPlugin --clobber
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
node_modules/
dist/
coverage/
build/
bundle.js
bundle-pi.js
fun.shiro.ytmd.sdPlugin/
DistributionTool.exe
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"scripts": {
"watch": "start watchify --debug -p tsify src/ytmd-pi.ts -o bundle-pi.js && start watchify --debug -p tsify src/ytmd.ts -o bundle.js",
"build": "browserify -p tsify src/ytmd-pi.ts | terser -cm --comments false -o bundle-pi.js && browserify -p tsify src/ytmd.ts | terser -cm --comments false -o bundle.js"
"build": "node scripts/build.js"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"packages": {
".": {
"release-type": "node",
"draft": true,
"include-component-in-tag": false,
"extra-files": [
"src/version.ts",
Expand Down
81 changes: 81 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const fs = require('fs');
const browserify = require('../node_modules/browserify');
const tsify = require('../node_modules/tsify');
const {minify_sync} = require('../node_modules/terser');
const {execSync} = require('child_process');
// Create release folder
console.log('Creating release folder');
if (fs.existsSync('build')) {
execSync('rmdir /s /q build');
}
fs.mkdirSync('build');

// Create plugin folder
console.log('Creating plugin folder');
if (fs.existsSync('build/fun.shiro.ytmd.sdPlugin')) {
execSync('rmdir /s /q build/fun.shiro.ytmd.sdPlugin');
}
fs.mkdirSync('build/fun.shiro.ytmd.sdPlugin');

// Build plugin
console.log('Building plugin');

// I know, this is a mess, but it works.
browserify({entries: ['src/ytmd-pi.ts'], plugin: [tsify]}).bundle((err, buf) => {
if (err) {
console.error(err);
return;
}
const minified = minify_sync(buf.toString(), {
mangle: {
toplevel: true
},
output: {
comments: false
}
});
if (minified.error) {
console.error(minified.error);
return;
}
fs.writeFileSync('build/fun.shiro.ytmd.sdPlugin/bundle-pi.js', minified.code);

browserify({entries: ['src/ytmd.ts'], plugin: [tsify]}).bundle((err, buf) => {
if (err) {
console.error(err);
return;
}
const minified = minify_sync(buf.toString(), {
mangle: {
toplevel: true
},
output: {
comments: false
}
});
if (minified.error) {
console.error(minified.error);
return;
}
fs.writeFileSync('build/fun.shiro.ytmd.sdPlugin/bundle.js', minified.code);

// Copy files
console.log('Copying files');
fs.copyFileSync('sdpi.css', 'build/fun.shiro.ytmd.sdPlugin/sdpi.css');
fs.copyFileSync('manifest.json', 'build/fun.shiro.ytmd.sdPlugin/manifest.json');
fs.copyFileSync('property-inspector.html', 'build/fun.shiro.ytmd.sdPlugin/property-inspector.html');
fs.copyFileSync('action.html', 'build/fun.shiro.ytmd.sdPlugin/action.html');
fs.cpSync('icons', 'build/fun.shiro.ytmd.sdPlugin/icons', {recursive: true});

// Run distribution tool
console.log('Running distribution tool');
execSync('DistributionTool.exe -b -i build/fun.shiro.ytmd.sdPlugin -o build');

// Clean up
console.log('Cleaning up');
fs.rmSync('build/fun.shiro.ytmd.sdPlugin', {recursive: true});

// Done building release, check the build folder
console.log('Done building release, check the build folder');
});
});

0 comments on commit 7441d63

Please sign in to comment.