Skip to content

Commit

Permalink
chore(ci): move publish code to node scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Jun 8, 2024
1 parent 8a42274 commit f82aa93
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,7 @@ jobs:

- name: Run release script
run: npx tsx ./scripts/release.ts

- name: Publish to NPM
run: npm publish --ignore-scripts || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to VSCE
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 }} --no-dependencies || true
env:
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@
"mem": "^8.1.1",
"phpfmt": "^0.0.7"
},
"packageManager": "pnpm@9.0.6",
"packageManager": "pnpm@9.2.0",
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
Expand Down
34 changes: 34 additions & 0 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable n/no-sync */
/* eslint no-console: error */
import path from 'path';
import os from 'os';
import { execSync } from 'child_process';
import fs from 'fs/promises';
import phpfmt from 'phpfmt';
import AdmZip from 'adm-zip';
Expand All @@ -18,6 +20,38 @@ const changelogPath = path.join(__dirname, '../CHANGELOG.md');

void (async () => {
try {
// Publish to NPM
try {
execSync('npm publish --ignore-scripts', {
stdio: 'inherit',
env: {
NODE_AUTH_TOKEN: process.env.NODE_AUTH_TOKEN
}
});
} catch (err) {
consola.error(err);
}

// Publish to VSCE
try {
execSync(`vsce publish -p ${process.env.VSCE_TOKEN} --no-dependencies`, {
stdio: 'inherit'
});
} catch (err) {
consola.error(err);
}

// Publish to OVSX
try {
execSync(`ovsx publish -p ${process.env.OVSX_TOKEN} --no-dependencies`, {
stdio: 'inherit'
});
} catch (err) {
consola.error(err);
}

process.exit(1);

const pkg = JSON.parse(String(await fs.readFile(pkgJsonPath)));
const currentVersion = pkg.version;

Expand Down

0 comments on commit f82aa93

Please sign in to comment.