Skip to content

Commit 1335027

Browse files
committed
Add pre-release workflow for automated VSIX packaging and release
1 parent c39d927 commit 1335027

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

.github/workflows/pre-release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# This workflow creates a pre-release with a .vsix package attached
2+
# It triggers on pushes to development branches or when tags are created
3+
4+
name: Pre-release
5+
6+
on:
7+
push:
8+
branches:
9+
- alt
10+
workflow_dispatch: # Allow manual trigger
11+
12+
jobs:
13+
pre-release:
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
contents: write # Required to create releases
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20.x'
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Generate ANTLR files
33+
run: |
34+
npm run antlr
35+
npm run build:textMate
36+
# Handle ANTLR output location issue
37+
if [ -d "./server/src/antlr/out/server/src/antlr" ]; then
38+
mv ./server/src/antlr/out/server/src/antlr/* ./server/src/antlr/out/
39+
fi
40+
41+
- name: Build extension
42+
run: npm run package
43+
44+
- name: Install vsce
45+
run: npm install -g vsce
46+
47+
- name: Package extension
48+
run: npm run vsix
49+
50+
- name: Get package info
51+
id: package
52+
run: |
53+
PACKAGE_NAME=$(node -p "require('./package.json').name")
54+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
55+
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
56+
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
57+
echo "vsix_name=$PACKAGE_NAME-$PACKAGE_VERSION.vsix" >> $GITHUB_OUTPUT
58+
59+
- name: Generate release tag
60+
id: tag
61+
run: |
62+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
63+
# If triggered by a tag, use that tag
64+
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
65+
else
66+
# Generate a pre-release tag with timestamp
67+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
68+
BRANCH_NAME=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9.-]/-/g')
69+
echo "tag=pre-${{ steps.package.outputs.version }}-$BRANCH_NAME-$TIMESTAMP" >> $GITHUB_OUTPUT
70+
fi
71+
72+
- name: Create pre-release
73+
id: create_release
74+
uses: actions/create-release@v1
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
with:
78+
tag_name: ${{ steps.tag.outputs.tag }}
79+
release_name: Pre-release ${{ steps.tag.outputs.tag }}
80+
body: |
81+
🚀 **Pre-release build**
82+
83+
This is an automated pre-release build from branch `${{ github.ref_name }}`.
84+
85+
**Package Info:**
86+
- Version: ${{ steps.package.outputs.version }}
87+
- Commit: ${{ github.sha }}
88+
- Branch: ${{ github.ref_name }}
89+
- Build Time: ${{ github.run_id }}
90+
91+
**Installation:**
92+
1. Download the `.vsix` file from the assets below
93+
2. In VS Code, go to Extensions view (Ctrl+Shift+X)
94+
3. Click the "..." menu and select "Install from VSIX..."
95+
4. Select the downloaded `.vsix` file
96+
97+
⚠️ **Note:** This is a pre-release version and may contain bugs or incomplete features.
98+
draft: false
99+
prerelease: true
100+
101+
- name: Upload VSIX asset
102+
uses: actions/upload-release-asset@v1
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
with:
106+
upload_url: ${{ steps.create_release.outputs.upload_url }}
107+
asset_path: ./${{ steps.package.outputs.vsix_name }}
108+
asset_name: ${{ steps.package.outputs.vsix_name }}
109+
asset_content_type: application/zip

0 commit comments

Comments
 (0)