Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Apr 28, 2024
1 parent 38775b2 commit bd77d8d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cron.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cron
name: Release

on:
schedule:
Expand Down Expand Up @@ -51,11 +51,11 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to VSCE
run: vsce publish -p ${{ env.VSCE_TOKEN }} || true
run: vsce publish -p ${{ env.VSCE_TOKEN }} --no-dependencies || true
env:
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}

- name: Publish to OVSX
run: ovsx publish -p ${{ env.OVSX_TOKEN }} || true
run: ovsx publish -p ${{ env.OVSX_TOKEN }} --no-dependencies || true
env:
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-phpfmt",
"displayName": "phpfmt - PHP formatter",
"version": "1.2.10",
"version": "1.2.9",
"description": "Integrates phpfmt into VS Code",
"main": "./dist/extension",
"scripts": {
Expand Down Expand Up @@ -634,6 +634,7 @@
"@typescript-eslint/parser": "^7.1.1",
"@vscode/test-electron": "^2.3.9",
"adm-zip": "^0.5.10",
"consola": "^3.2.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-console: error */
import path from 'path';
import os from 'os';
import fs from 'fs/promises';
Expand All @@ -7,6 +8,7 @@ import md5 from 'md5';
import * as semver from 'semver';
import debug from 'debug';
import { simpleGit } from 'simple-git';
import { consola } from 'consola';
import { downloadFile } from '../src/utils';

debug.enable('simple-git,simple-git:*');
Expand All @@ -25,7 +27,7 @@ void (async () => {
'version.txt'
);

console.log(`Download url: ${pharUrl}`);
consola.info(`Download url: ${pharUrl}`);

const tmpDir = path.join(os.tmpdir(), 'vscode-phpfmt');
await fs.mkdir(tmpDir, { recursive: true });
Expand All @@ -36,45 +38,49 @@ void (async () => {
`${phpfmt.v2.pharName}.version.txt`
);

console.log('Downloading vsix...');
consola.info('Downloading vsix...');
await downloadFile(
`https://kokororin.gallery.vsassets.io/_apis/public/gallery/publisher/kokororin/extension/vscode-phpfmt/${currentVersion}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`,
currentVsixPath
);

const stats = await fs.stat(currentVsixPath);
if (stats.size < 10000) {
console.log('Download vsix failed');
consola.error('Download vsix failed');
return;
}

const zip = new AdmZip(currentVsixPath);
const zipEntries = zip.getEntries();
const entry = zipEntries.find(
o =>
o.entryName === `extension/node_modules/phpfmt/v2/${phpfmt.v2.pharName}`
o => o.entryName === `extension/dist/${phpfmt.v2.pharName}`
);
if (entry == null) {
consola.error('Not found phar in vsix');
return;
}

const currentPharData = String(entry?.getData());
const currentMd5 = md5(currentPharData);
console.log(`Current md5: ${currentMd5}`);
consola.info(`Current md5: ${currentMd5}`);

console.log('Downloading latest phar...');
consola.info('Downloading latest phar...');
await downloadFile(pharUrl, latestPharPath);
await downloadFile(pharVersionUrl, latestPharVersionPath);
const latestPharData = String(await fs.readFile(latestPharPath));
const latestPharVersion = String(await fs.readFile(latestPharVersionPath));
console.log(`Latest phar version: ${latestPharVersion}`);
consola.info(`Latest phar version: ${latestPharVersion}`);

const latestMd5 = md5(latestPharData);
console.log(`Latest md5: ${latestMd5}`);
consola.info(`Latest md5: ${latestMd5}`);

if (currentMd5 === latestMd5) {
console.log('Md5 is same');
consola.info('Md5 is same');
return;
}

const newVersion = semver.inc(currentVersion, 'patch');
console.log(`New version: ${newVersion}`);
consola.info(`New version: ${newVersion}`);

let changelogData = String(await fs.readFile(changelogPath));
changelogData = `### ${newVersion}
Expand Down Expand Up @@ -106,7 +112,7 @@ ${changelogData}`;
.push()
.pushTags();
} catch (err) {
console.error(err);
consola.error(err);
process.exit(1);
}
})();

0 comments on commit bd77d8d

Please sign in to comment.