Skip to content

Commit d93abc7

Browse files
authored
ci: publish npm and extensions by CI (#122)
Signed-off-by: fi3ework <[email protected]>
1 parent 2be5909 commit d93abc7

File tree

3 files changed

+119
-2
lines changed

3 files changed

+119
-2
lines changed

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: 🚀 Release packages
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to release'
8+
required: true
9+
default: 'main'
10+
npm_tag:
11+
type: choice
12+
description: 'Specify npm tag'
13+
required: true
14+
default: 'alpha'
15+
options:
16+
- alpha
17+
- beta
18+
- rc
19+
- canary
20+
- latest
21+
extension_type:
22+
type: choice
23+
description: 'Specify the release type of extension'
24+
required: true
25+
default: pre-release
26+
options:
27+
- official
28+
- pre-release
29+
30+
to_release:
31+
description: 'Packages to release'
32+
type: choice
33+
required: true
34+
options:
35+
- all
36+
- npm
37+
- extension
38+
39+
env:
40+
GO_VERSION: '1.24.1'
41+
42+
jobs:
43+
publish:
44+
name: Build
45+
env:
46+
release_npm: ${{ inputs.to_release == 'all' || inputs.to_release == 'npm' }}
47+
release_extension: ${{ inputs.to_release == 'all' || inputs.to_release == 'extension' }}
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 1
54+
ref: ${{ github.event.inputs.branch }}
55+
56+
- name: Setup Node.js
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '24'
60+
61+
- name: Setup Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: ${{ env.GO_VERSION }}
65+
66+
- name: Install pnpm
67+
run: corepack enable
68+
69+
- name: Install dependencies
70+
run: pnpm install --frozen-lockfile
71+
72+
- name: Format code
73+
run: pnpm format:check
74+
75+
- name: TypeCheck
76+
run: pnpm typecheck
77+
78+
- name: Lint code
79+
run: pnpm lint
80+
81+
- name: Build packages
82+
run: pnpm build
83+
84+
- name: Test on Linux
85+
if: runner.os == 'Linux'
86+
run: xvfb-run -a pnpm -r test
87+
88+
- name: Publish npm packages
89+
if: env.release_npm == 'true'
90+
env:
91+
NPM_TOKEN: ${{ secrets.RSLINT_NPM_TOKEN }}
92+
run: |
93+
npm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
94+
pnpm -r publish --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }}
95+
96+
- name: Build and publish to Microsoft VS Code Marketplace
97+
if: env.release_extension == 'true'
98+
env:
99+
VSCE_PAT: ${{ secrets.RSLINT_VSCE_PAT }}
100+
run: |
101+
if [ "${{ github.event.inputs.extension_type }}" = "pre-release" ]; then
102+
pnpm publish:vsce --prerelease
103+
else
104+
pnpm publish:vsce
105+
fi
106+
107+
- name: Build and publish to Open VSX Registry
108+
if: env.release_extension == 'true'
109+
env:
110+
OVSX_PAT: ${{ secrets.RSLINT_OVSX_PAT }}
111+
run: |
112+
if [ "${{ github.event.inputs.extension_type }}" = "pre-release" ]; then
113+
pnpm publish:ovsx --prerelease
114+
else
115+
pnpm publish:ovsx
116+
fi

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build": "pnpm -r build",
1717
"build:npm": "zx scripts/build-npm.mjs",
1818
"version": "zx scripts/version.mjs",
19-
"release": "pnpm publish -r --no-git-checks ",
19+
"release": "pnpm publish -r --no-git-checks",
2020
"publish:vsce": "zx scripts/publish-marketplace.mjs",
2121
"publish:ovsx": "zx scripts/publish-marketplace.mjs --marketplace=ovsx",
2222
"format": "prettier --ignore-path=.prettierignore --config=.prettierrc.json --write .",

scripts/publish-marketplace.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import fs from 'fs';
33
import { argv } from 'zx';
44
const marketplace = argv.marketplace || 'vsce';
5+
const prerelease = argv.prerelease || false;
56

67
$.verbose = true;
78
async function publish_all() {
@@ -30,7 +31,7 @@ async function publish_all() {
3031
console.log(`Dry run: Skipping actual publish for ${os}-${arch}`);
3132
continue;
3233
}
33-
await $`cd packages/vscode-extension && pnpm ${marketplace} publish --packagePath ./rslint-${os}-${arch}-${version}.vsix `;
34+
await $`cd packages/vscode-extension && pnpm ${marketplace} publish --packagePath ./rslint-${os}-${arch}-${version}.vsix ${prerelease ? '--pre-release' : ''}`;
3435
console.log(`Finish Publishing v${version} for ${os}-${arch}.`);
3536
}
3637
}

0 commit comments

Comments
 (0)