Skip to content

Commit fe1d899

Browse files
committed
Update workflow to differentiate between experimental and stable releases
1 parent 964daf5 commit fe1d899

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

.github/workflows/publish.yaml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
name: Publish Extension
22

33
on:
4+
# Stable releases: triggered by GitHub release events
45
release:
56
types: [released]
67

8+
# Experimental builds: triggered by pushes to the experimental branch
9+
push:
10+
branches:
11+
- experimental
12+
713
jobs:
814
build:
915
runs-on: ubuntu-latest
1016
steps:
11-
# 1. Check-out repository
1217
- name: Checkout
1318
uses: actions/checkout@v4
1419
with:
15-
fetch-depth: 0 # This ensures all tags are fetched
20+
fetch-depth: 0
1621

17-
- name: Checkout tag
18-
run: git checkout ${GITHUB_REF#refs/tags/}
22+
# For stable releases, the ref is a tag; for experimental, it's a branch.
23+
# We only need to checkout the specific ref when it's a release event.
24+
- name: Checkout ref
25+
run: |
26+
if [ "${{ github.event_name }}" = "release" ]; then
27+
git checkout ${GITHUB_REF#refs/tags/}
28+
else
29+
git checkout experimental
30+
fi
1931
2032
- name: Make sure version isn't odd
2133
run: |
2234
node scripts/versionCheck.js
2335
24-
# 2. Install npm dependencies
2536
- name: Use Node.js from .nvmrc
2637
uses: actions/setup-node@v4
2738
with:
@@ -34,25 +45,29 @@ jobs:
3445
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
3546

3647
- name: Install Dependencies
48+
run: npm ci
49+
50+
# If on the experimental branch, modify displayName in package.json
51+
- name: Update extension name for Experimental release
52+
if: ${{ github.ref_name == 'experimental' }}
3753
run: |
38-
npm ci
54+
sed -i 's/"displayName": "Your Extension Name"/"displayName": "Your Extension Name (Experimental)"/' package.json
3955
40-
# 3. Package the extension
4156
- name: Package the extension
4257
run: npx vsce package --no-dependencies
4358

44-
# 4. Upload the .vsix as an artifact
4559
- uses: actions/upload-artifact@v4
4660
with:
4761
name: extension
4862
path: '*.vsix'
4963

5064
release:
65+
# Stable release job
5166
permissions:
5267
contents: write
5368
runs-on: ubuntu-latest
54-
needs:
55-
- build
69+
needs: build
70+
if: ${{ github.event_name == 'release' }}
5671
steps:
5772
- name: Checkout
5873
uses: actions/checkout@v4
@@ -62,7 +77,6 @@ jobs:
6277
git config --local user.email "[email protected]"
6378
git config --local user.name "CodeStory Team"
6479
65-
# Download the .vsix artifacts
6680
- uses: actions/download-artifact@v4
6781
with:
6882
pattern: '*extension'
@@ -73,18 +87,17 @@ jobs:
7387
uses: softprops/action-gh-release@v2
7488
with:
7589
tag_name: ${{ github.ref_name }}
76-
files: |
77-
vsix-artifacts/*.vsix
90+
files: vsix-artifacts/*.vsix
7891
repository: codestoryai/extension
7992

8093
publish:
94+
# Experimental publish job
8195
runs-on: ubuntu-latest
82-
needs:
83-
- build
96+
needs: build
8497
permissions:
8598
contents: write
99+
if: ${{ github.event_name == 'push' && github.ref_name == 'experimental' }}
86100
steps:
87-
# 0. Setup git
88101
- name: Checkout
89102
uses: actions/checkout@v4
90103

@@ -93,25 +106,20 @@ jobs:
93106
git config --local user.email "[email protected]"
94107
git config --local user.name "CodeStory Team"
95108
96-
- name: Pull latest changes from release
97-
run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }}
109+
- name: Pull latest changes from experimental
110+
run: git checkout experimental
98111

99-
# 1. Download the artifacts
100112
- uses: actions/download-artifact@v4
101113
with:
102114
pattern: '*extension'
103115
path: vsix-artifacts
104116
merge-multiple: true
105117

106-
# 2. Publish the extension to VS Code Marketplace
107118
- name: Publish to VS Code Marketplace
108-
run: |
109-
npx vsce publish --packagePath vsix-artifacts/*.vsix
119+
run: npx vsce publish --packagePath vsix-artifacts/*.vsix
110120
env:
111121
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
112122

113-
# 3. Publish the extension to Open VSX Registry
114123
- name: Publish (Open VSX Registry)
115124
continue-on-error: true
116-
run: |
117-
npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath vsix-artifacts/*.vsix
125+
run: npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath vsix-artifacts/*.vsix

0 commit comments

Comments
 (0)