Skip to content

Commit 116c94f

Browse files
committed
Package VSIX on every CI run and merge to main
* Publish pre-release on tag push "v*-pre"
1 parent 46f1ab4 commit 116c94f

File tree

4 files changed

+92
-85
lines changed

4 files changed

+92
-85
lines changed

.github/workflows/ci.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,58 @@ jobs:
4141
- run: yarn
4242

4343
- run: yarn test:ci
44+
45+
package:
46+
name: Package
47+
runs-on: ubuntu-22.04
48+
needs: [lint, test]
49+
outputs:
50+
packageName: ${{ steps.setup.outputs.packageName }}
51+
version: ${{ steps.version.outputs.version }}
52+
steps:
53+
- uses: actions/checkout@v5
54+
55+
- uses: actions/setup-node@v5
56+
with:
57+
node-version: "22"
58+
59+
- name: Install dependencies
60+
run: |
61+
yarn
62+
npm install -g @vscode/vsce
63+
64+
- name: Get version from package.json
65+
id: version
66+
run: |
67+
VERSION=$(node -e "console.log(require('./package.json').version)")
68+
echo "version=$VERSION" >> $GITHUB_OUTPUT
69+
echo "Version: $VERSION"
70+
71+
- name: Setup package path
72+
id: setup
73+
run: |
74+
EXTENSION_NAME=$(node -e "console.log(require('./package.json').name)")
75+
# Add commit SHA for CI builds
76+
SHORT_SHA=$(git rev-parse --short HEAD)
77+
PACKAGE_NAME="${EXTENSION_NAME}-${{ steps.version.outputs.version }}-${SHORT_SHA}.vsix"
78+
echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT
79+
80+
- name: Package extension
81+
run: vsce package --out "${{ steps.setup.outputs.packageName }}"
82+
83+
- name: Upload artifact (PR)
84+
if: github.event_name == 'pull_request'
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: extension-pr-${{ github.event.pull_request.number }}
88+
path: ${{ steps.setup.outputs.packageName }}
89+
if-no-files-found: error
90+
retention-days: 7
91+
92+
- name: Upload artifact (main)
93+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: extension-main-${{ github.sha }}
97+
path: ${{ steps.setup.outputs.packageName }}
98+
if-no-files-found: error

.github/workflows/pre-release.yaml

Lines changed: 14 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
name: Pre-Release
22
on:
33
push:
4-
branches:
5-
- main
4+
tags:
5+
- "v*-pre"
6+
7+
permissions:
8+
# Required to publish a release
9+
contents: write
10+
pull-requests: read
611

712
jobs:
813
package:
@@ -23,26 +28,14 @@ jobs:
2328
yarn
2429
npm install -g @vscode/vsce
2530
26-
- name: Generate pre-release version
31+
- name: Extract version from tag
2732
id: version
2833
run: |
29-
BASE_VERSION=$(node -e "console.log(require('./package.json').version)")
30-
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
31-
32-
PRE_MINOR=$((MINOR + 1))
33-
34-
DATE_PREFIX=$(date +%Y%m%d)
35-
BUILD_SUFFIX=$(printf "%02d" $((GITHUB_RUN_NUMBER % 100)))
36-
DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}"
37-
38-
# Final version: MAJOR.(MINOR+1).YYYYMMDDNN
39-
NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}"
40-
41-
echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT
42-
echo "Pre-release version: $NUMERIC_VERSION"
43-
44-
# Update package.json with the numeric version
45-
npm version $NUMERIC_VERSION --no-git-tag-version
34+
# Extract version from tag (remove 'v' prefix and '-pre' suffix)
35+
TAG_NAME=${GITHUB_REF#refs/tags/v}
36+
VERSION=${TAG_NAME%-pre}
37+
echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
echo "Pre-release version: $VERSION"
4639
4740
- name: Setup package path
4841
id: setup
@@ -60,10 +53,9 @@ jobs:
6053
name: extension-${{ steps.version.outputs.version }}
6154
path: ${{ steps.setup.outputs.packageName }}
6255
if-no-files-found: error
63-
retention-days: 7
6456

6557
publish:
66-
name: Publish to Marketplaces
58+
name: Publish Extension and Create Pre-Release
6759
needs: package
6860
uses: ./.github/workflows/publish-extension.yaml
6961
with:
@@ -73,42 +65,3 @@ jobs:
7365
secrets:
7466
VSCE_PAT: ${{ secrets.VSCE_PAT }}
7567
OVSX_PAT: ${{ secrets.OVSX_PAT }}
76-
77-
publishGH:
78-
name: Update Latest Pre-Release
79-
runs-on: ubuntu-22.04
80-
needs: package
81-
permissions:
82-
contents: write
83-
steps:
84-
- uses: actions/checkout@v5
85-
86-
- uses: actions/download-artifact@v5
87-
with:
88-
name: extension-${{ needs.package.outputs.version }}
89-
90-
- name: Update Rolling Release
91-
env:
92-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
run: |
94-
# Delete old release and tag
95-
gh release delete latest-pre-release --cleanup-tag -y || true
96-
97-
# Create new release with heredoc for formatting
98-
cat << EOF | gh release create latest-pre-release \
99-
--target ${{ github.sha }} \
100-
--title "Latest Pre-Release Build" \
101-
--notes-file - \
102-
--prerelease \
103-
--latest=false \
104-
${{ needs.package.outputs.packageName }}
105-
## Latest Pre-Release: v${{ needs.package.outputs.version }}
106-
107-
**Build:** #${{ github.run_number }} | **Commit:** ${{ github.sha }}
108-
109-
## Changes
110-
${{ github.event.head_commit.message }}
111-
112-
---
113-
*This release is automatically updated with each push to main. The tag \`latest-pre-release\` always points to the most recent build.*
114-
EOF

.github/workflows/publish-extension.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,24 @@ jobs:
7474
else
7575
ovsx publish "./${{ inputs.packageName }}" -p ${{ secrets.OVSX_PAT }}
7676
fi
77+
78+
publishGH:
79+
name: Create GitHub ${{ inputs.isPreRelease && 'Pre-' || '' }}Release
80+
runs-on: ubuntu-22.04
81+
permissions:
82+
contents: write
83+
steps:
84+
- uses: actions/checkout@v5
85+
86+
- uses: actions/download-artifact@v5
87+
with:
88+
name: extension-${{ inputs.version }}
89+
90+
- name: Create ${{ inputs.isPreRelease && 'Pre-' || '' }}Release
91+
uses: marvinpinto/action-automatic-releases@latest
92+
with:
93+
repo_token: ${{ secrets.GITHUB_TOKEN }}
94+
prerelease: ${{ inputs.isPreRelease }}
95+
draft: true
96+
title: "${{ inputs.isPreRelease && 'Pre-' || '' }}Release v${{ inputs.version }}"
97+
files: ${{ inputs.packageName }}

.github/workflows/release.yaml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
tags:
55
- "v*"
6+
- "!v*-pre"
67

78
permissions:
89
# Required to publish a release
@@ -52,10 +53,9 @@ jobs:
5253
name: extension-${{ steps.version.outputs.version }}
5354
path: ${{ steps.setup.outputs.packageName }}
5455
if-no-files-found: error
55-
retention-days: 30
5656

5757
publish:
58-
name: Publish to Marketplaces
58+
name: Publish Extension and Create Release
5959
needs: package
6060
uses: ./.github/workflows/publish-extension.yaml
6161
with:
@@ -65,25 +65,3 @@ jobs:
6565
secrets:
6666
VSCE_PAT: ${{ secrets.VSCE_PAT }}
6767
OVSX_PAT: ${{ secrets.OVSX_PAT }}
68-
69-
publishGH:
70-
name: Create GitHub Release
71-
runs-on: ubuntu-22.04
72-
needs: package
73-
permissions:
74-
contents: write
75-
steps:
76-
- uses: actions/checkout@v5
77-
78-
- uses: actions/download-artifact@v5
79-
with:
80-
name: extension-${{ needs.package.outputs.version }}
81-
82-
- name: Create Release
83-
uses: marvinpinto/action-automatic-releases@latest
84-
with:
85-
repo_token: ${{ secrets.GITHUB_TOKEN }}
86-
prerelease: false
87-
draft: true
88-
title: "Release v${{ needs.package.outputs.version }}"
89-
files: ${{ needs.package.outputs.packageName }}

0 commit comments

Comments
 (0)