Skip to content

Commit ad4fcfa

Browse files
zombieyangAbdullahAlfaraj
authored andcommitted
add a publish workflow,
Squashed commit of the following: commit 7a7699d And fixed formatting of package-lock.json Author: unknown <[email protected]> Date: Sat Sep 9 18:08:53 2023 +0800 add a publish workflow
1 parent d748a89 commit ad4fcfa

File tree

9 files changed

+1238
-117
lines changed

9 files changed

+1238
-117
lines changed

Diff for: .github/workflows/publish.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: publish ccx and make tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: 'tag name'
8+
required: true
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Create Release Asset
18+
shell: bash
19+
run: |
20+
cd $GITHUB_WORKSPACE
21+
npm i
22+
npm run publish
23+
node build-script/pack-ccx.mjs --version ${{ github.event.inputs.tag_name }}
24+
25+
- name: Create Release
26+
id: create_release
27+
uses: actions/create-release@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
tag_name: v${{ github.event.inputs.tag_name }}
32+
release_name: v${{ github.event.inputs.tag_name }}
33+
draft: true
34+
prerelease: false
35+
36+
- name: Upload ZIP
37+
uses: actions/upload-release-asset@v1
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
with:
41+
upload_url: ${{ steps.create_release.outputs.upload_url }}
42+
asset_path: ./Auto.Photoshop.SD.plugin_v${{ github.event.inputs.tag_name }}.zip
43+
asset_name: Auto.Photoshop.SD.plugin_v${{ github.event.inputs.tag_name }}.zip
44+
asset_content_type: application/zip
45+
46+
- name: Upload CCX
47+
uses: actions/upload-release-asset@v1
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
upload_url: ${{ steps.create_release.outputs.upload_url }}
52+
asset_path: ./Auto.Photoshop.SD.plugin_v${{ github.event.inputs.tag_name }}.ccx
53+
asset_name: Auto.Photoshop.SD.plugin_v${{ github.event.inputs.tag_name }}.ccx
54+
asset_content_type: application/zip

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ experimental/
1717
start_server.sh
1818
start_server.bat
1919
*.ccx
20+
*.zip
2021
expanded_mask.png
2122
original_mask.png
2223
/config

Diff for: build-script/pack-ccx.mjs

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import chalk from 'chalk';
2+
import { program } from 'commander';
3+
import { createWriteStream, readFileSync, statSync, writeFileSync } from 'fs';
4+
import { globSync } from 'glob';
5+
import { dirname, join, relative } from 'path';
6+
import { fileURLToPath } from 'url';
7+
import yazl from 'yazl'
8+
9+
const __dirname = dirname(fileURLToPath(import.meta.url))
10+
const basePath = join(__dirname, '..')
11+
12+
program
13+
.requiredOption("--version <platform>", "the target platform")
14+
.parse();
15+
16+
const version = program.opts().version;
17+
if (!version.match(/\d+\.\d+\.\d+/)) throw new Error(`invalid version format: ${version}`);
18+
19+
console.log(chalk.cyan("rewriting manifest.json's version field to " + version));
20+
const manifest = JSON.parse(readFileSync(`${basePath}/manifest.json`, 'utf-8'));
21+
manifest.version = version;
22+
writeFileSync(`${basePath}/manifest.json`, JSON.stringify(manifest));
23+
24+
console.log(chalk.cyan("rewriting package.json's version field to " + version));
25+
const packageJSON = JSON.parse(readFileSync(`${basePath}/package.json`, 'utf-8'));
26+
packageJSON.version = version;
27+
writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJSON));
28+
29+
console.log(chalk.cyan("packaging .ccx"));
30+
const zipList = [
31+
'./manifest.json',
32+
'./i18n/**/*',
33+
'./icon/**/*',
34+
'./jimp/**/*',
35+
'./scripts/**/*',
36+
'./typescripts/dist/**/*',
37+
'./utility/**/*',
38+
'./server/**/*',
39+
'./*.js',
40+
'./package.json',
41+
'./tsconfig.json',
42+
'./*.html',
43+
'./*.py',
44+
'./*.txt',
45+
'./*.md',
46+
'./*.png',
47+
]
48+
49+
const zipfile = new yazl.ZipFile();
50+
51+
zipList.forEach(globber => {
52+
globSync(
53+
join(basePath, globber).replace(/\\/g, '/')
54+
).forEach(filepath => {
55+
if (statSync(filepath).isDirectory()) return;
56+
57+
const rpath = relative(basePath, filepath);
58+
zipfile.addFile(filepath, rpath)
59+
})
60+
})
61+
62+
zipfile.outputStream.pipe(
63+
createWriteStream(join(basePath, `Auto.Photoshop.SD.plugin_v${version}.ccx`))
64+
);
65+
zipfile.outputStream.pipe(
66+
createWriteStream(join(basePath, `Auto.Photoshop.SD.plugin_v${version}.zip`))
67+
);
68+
69+
zipfile.end()

Diff for: webpack.config.js renamed to build-script/webpack.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const CopyPlugin = require('copy-webpack-plugin')
44

55
module.exports = {
66
entry: {
7-
bundle: './typescripts/entry.ts',
7+
bundle: path.resolve(__dirname, '../typescripts/entry.ts'),
88
},
99
output: {
10-
path: path.resolve(__dirname, './typescripts/dist'),
10+
path: path.resolve(__dirname, '../typescripts/dist'),
1111
filename: '[name].js',
1212
libraryTarget: 'commonjs2',
1313
},
@@ -35,7 +35,7 @@ module.exports = {
3535
loader: 'ts-loader',
3636
exclude: /node_modules/,
3737
options: {
38-
configFile: 'tsconfig.json',
38+
configFile: path.resolve(__dirname, '../typescripts/tsconfig.json'),
3939
},
4040
},
4141
{

Diff for: index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const _log = console.log
88
const _warn = console.warn
99
const _error = console.error
1010
let g_timer_value = 300 // temporary global variable for testing the timer pause function
11-
12-
let g_version = 'v1.3.2'
13-
11+
let g_version = 'v' + JSON.parse(require('fs').readFileSync("plugin:manifest.json", 'utf-8')).version
1412
let g_sd_url = 'http://127.0.0.1:7860'
1513
let g_online_data_url =
1614
'https://raw.githubusercontent.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/master/utility/online_data.json'

Diff for: manifest.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{
22
"id": "auto.photoshop.stable.diffusion.plugin",
33
"name": "Auto Photoshop Stable Diffusion Plugin",
4-
"version": "1.1.0",
5-
"host": [
6-
{
7-
"app": "PS",
8-
"minVersion": "24.0.0"
9-
}
10-
],
4+
"version": "1.3.1",
5+
"host": {
6+
"app": "PS",
7+
"minVersion": "24.0.0"
8+
},
119
"main": "index.html",
1210
"manifestVersion": 5,
1311
"requiredPermissions": {

0 commit comments

Comments
 (0)