Skip to content

Commit d39361d

Browse files
committed
Unified the extension publishing logic
1 parent 838debd commit d39361d

File tree

3 files changed

+104
-97
lines changed

3 files changed

+104
-97
lines changed

.github/workflows/pre-release.yaml

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
yarn
24-
npm install -g @vscode/vsce ovsx
24+
npm install -g @vscode/vsce
2525
2626
- name: Generate pre-release version
2727
id: version
@@ -36,10 +36,9 @@ jobs:
3636
DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}"
3737
3838
# Final version: MAJOR.(MINOR+1).YYYYMMDDNN
39-
NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}${{ github.run_number }}"
39+
NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}"
4040
4141
echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT
42-
4342
echo "Pre-release version: $NUMERIC_VERSION"
4443
4544
# Update package.json with the numeric version
@@ -57,56 +56,22 @@ jobs:
5756
- name: Upload artifact
5857
uses: actions/upload-artifact@v4
5958
with:
60-
name: extension-build-${{ github.run_number }}
59+
name: extension-${{ steps.version.outputs.version }}
6160
path: ${{ steps.setup.outputs.packageName }}
6261
if-no-files-found: error
6362
retention-days: 7
6463

65-
publishMS:
66-
name: Publish to VS Marketplace
67-
runs-on: ubuntu-22.04
64+
publish:
65+
name: Publish to Marketplaces
6866
needs: package
69-
steps:
70-
- uses: actions/checkout@v5
71-
72-
- uses: actions/setup-node@v5
73-
with:
74-
node-version: "22"
75-
76-
- name: Install vsce
77-
run: npm install -g @vscode/vsce
78-
79-
- uses: actions/download-artifact@v5
80-
with:
81-
name: extension-build-${{ github.run_number }}
82-
83-
- name: Publish to VS Marketplace
84-
run: |
85-
echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace"
86-
vsce publish --pre-release --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }}
87-
88-
publishOVSX:
89-
name: Publish to Open VSX
90-
runs-on: ubuntu-22.04
91-
needs: package
92-
steps:
93-
- uses: actions/checkout@v5
94-
95-
- uses: actions/setup-node@v5
96-
with:
97-
node-version: "22"
98-
99-
- name: Install ovsx
100-
run: npm install -g ovsx
101-
102-
- uses: actions/download-artifact@v5
103-
with:
104-
name: extension-build-${{ github.run_number }}
105-
106-
- name: Publish to Open VSX
107-
run: |
108-
echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX"
109-
ovsx publish "./${{ needs.package.outputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }}
67+
uses: ./.github/workflows/publish-extension.yaml
68+
with:
69+
version: ${{ needs.package.outputs.version }}
70+
packageName: ${{ needs.package.outputs.packageName }}
71+
isPreRelease: true
72+
secrets:
73+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
74+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
11075

11176
publishGH:
11277
name: Update Latest Pre-Release
@@ -119,7 +84,7 @@ jobs:
11984

12085
- uses: actions/download-artifact@v5
12186
with:
122-
name: extension-build-${{ github.run_number }}
87+
name: extension-${{ needs.package.outputs.version }}
12388

12489
- name: Update Rolling Release
12590
env:
@@ -144,5 +109,5 @@ jobs:
144109
${{ github.event.head_commit.message }}
145110
146111
---
147-
*This release is automatically updated with each push to main. The tag `latest-pre-release` always points to the most recent build.*
112+
*This release is automatically updated with each push to main. The tag \`latest-pre-release\` always points to the most recent build.*
148113
EOF
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Publish Extension
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
description: "Version to publish"
10+
packageName:
11+
required: true
12+
type: string
13+
description: "Package filename"
14+
isPreRelease:
15+
required: false
16+
type: boolean
17+
default: false
18+
description: "Whether this is a pre-release"
19+
secrets:
20+
VSCE_PAT:
21+
required: true
22+
OVSX_PAT:
23+
required: true
24+
25+
jobs:
26+
publishMS:
27+
name: Publish to VS Marketplace
28+
runs-on: ubuntu-22.04
29+
steps:
30+
- uses: actions/checkout@v5
31+
32+
- uses: actions/setup-node@v5
33+
with:
34+
node-version: "22"
35+
36+
- name: Install vsce
37+
run: npm install -g @vscode/vsce
38+
39+
- uses: actions/download-artifact@v5
40+
with:
41+
name: extension-${{ inputs.version }}
42+
43+
- name: Publish to VS Marketplace
44+
run: |
45+
echo "Publishing version ${{ inputs.version }} to VS Marketplace"
46+
if [ "${{ inputs.isPreRelease }}" = "true" ]; then
47+
vsce publish --pre-release --packagePath "./${{ inputs.packageName }}" -p ${{ secrets.VSCE_PAT }}
48+
else
49+
vsce publish --packagePath "./${{ inputs.packageName }}" -p ${{ secrets.VSCE_PAT }}
50+
fi
51+
52+
publishOVSX:
53+
name: Publish to Open VSX
54+
runs-on: ubuntu-22.04
55+
steps:
56+
- uses: actions/checkout@v5
57+
58+
- uses: actions/setup-node@v5
59+
with:
60+
node-version: "22"
61+
62+
- name: Install ovsx
63+
run: npm install -g ovsx
64+
65+
- uses: actions/download-artifact@v5
66+
with:
67+
name: extension-${{ inputs.version }}
68+
69+
- name: Publish to Open VSX
70+
run: |
71+
echo "Publishing version ${{ inputs.version }} to Open VSX"
72+
if [ "${{ inputs.isPreRelease }}" = "true" ]; then
73+
ovsx publish "./${{ inputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }}
74+
else
75+
ovsx publish "./${{ inputs.packageName }}" -p ${{ secrets.OVSX_PAT }}
76+
fi

.github/workflows/release.yaml

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install dependencies
2727
run: |
2828
yarn
29-
npm install -g @vscode/vsce ovsx
29+
npm install -g @vscode/vsce
3030
3131
- name: Extract version from tag
3232
id: version
@@ -48,56 +48,22 @@ jobs:
4848
- name: Upload artifact
4949
uses: actions/upload-artifact@v4
5050
with:
51-
name: extension-release-${{ steps.version.outputs.version }}
51+
name: extension-${{ steps.version.outputs.version }}
5252
path: ${{ steps.setup.outputs.packageName }}
5353
if-no-files-found: error
5454
retention-days: 30
5555

56-
publishMS:
57-
name: Publish to VS Marketplace
58-
runs-on: ubuntu-22.04
59-
needs: package
60-
steps:
61-
- uses: actions/checkout@v5
62-
63-
- uses: actions/setup-node@v5
64-
with:
65-
node-version: "22"
66-
67-
- name: Install vsce
68-
run: npm install -g @vscode/vsce
69-
70-
- uses: actions/download-artifact@v5
71-
with:
72-
name: extension-release-${{ needs.package.outputs.version }}
73-
74-
- name: Publish to VS Marketplace
75-
run: |
76-
echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace"
77-
vsce publish --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }}
78-
79-
publishOVSX:
80-
name: Publish to Open VSX
81-
runs-on: ubuntu-22.04
56+
publish:
57+
name: Publish to Marketplaces
8258
needs: package
83-
steps:
84-
- uses: actions/checkout@v5
85-
86-
- uses: actions/setup-node@v5
87-
with:
88-
node-version: "22"
89-
90-
- name: Install ovsx
91-
run: npm install -g ovsx
92-
93-
- uses: actions/download-artifact@v5
94-
with:
95-
name: extension-release-${{ needs.package.outputs.version }}
96-
97-
- name: Publish to Open VSX
98-
run: |
99-
echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX"
100-
ovsx publish "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.OVSX_PAT }}
59+
uses: ./.github/workflows/publish-extension.yaml
60+
with:
61+
version: ${{ needs.package.outputs.version }}
62+
packageName: ${{ needs.package.outputs.packageName }}
63+
isPreRelease: false
64+
secrets:
65+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
66+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
10167

10268
publishGH:
10369
name: Create GitHub Release
@@ -110,7 +76,7 @@ jobs:
11076

11177
- uses: actions/download-artifact@v5
11278
with:
113-
name: extension-release-${{ needs.package.outputs.version }}
79+
name: extension-${{ needs.package.outputs.version }}
11480

11581
- name: Create Release
11682
uses: marvinpinto/action-automatic-releases@latest

0 commit comments

Comments
 (0)