Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Package VSIX on every CI run and merge to main
* Publish pre-release on tag push "v*-pre"
  • Loading branch information
EhabY committed Oct 22, 2025
commit 2cff82f95d6bfd063e8c7594cf3989e07ed8db61
55 changes: 55 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,58 @@ jobs:
- run: yarn

- run: yarn test:ci

package:
name: Package
runs-on: ubuntu-22.04
needs: [lint, test]
outputs:
packageName: ${{ steps.setup.outputs.packageName }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v5

- uses: actions/setup-node@v5
with:
node-version: "22"

- name: Install dependencies
run: |
yarn
npm install -g @vscode/vsce

- name: Get version from package.json
id: version
run: |
VERSION=$(node -e "console.log(require('./package.json').version)")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Setup package path
id: setup
run: |
EXTENSION_NAME=$(node -e "console.log(require('./package.json').name)")
# Add commit SHA for CI builds
SHORT_SHA=$(git rev-parse --short HEAD)
PACKAGE_NAME="${EXTENSION_NAME}-${{ steps.version.outputs.version }}-${SHORT_SHA}.vsix"
echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT

- name: Package extension
run: vsce package --out "${{ steps.setup.outputs.packageName }}"

- name: Upload artifact (PR)
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: extension-pr-${{ github.event.pull_request.number }}
path: ${{ steps.setup.outputs.packageName }}
if-no-files-found: error
retention-days: 7

- name: Upload artifact (main)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: extension-main-${{ github.sha }}
path: ${{ steps.setup.outputs.packageName }}
if-no-files-found: error
75 changes: 14 additions & 61 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Pre-Release
on:
push:
branches:
- main
tags:
- "v*-pre"

permissions:
# Required to publish a release
contents: write
pull-requests: read

jobs:
package:
Expand All @@ -23,26 +28,14 @@ jobs:
yarn
npm install -g @vscode/vsce

- name: Generate pre-release version
- name: Extract version from tag
id: version
run: |
BASE_VERSION=$(node -e "console.log(require('./package.json').version)")
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"

PRE_MINOR=$((MINOR + 1))

DATE_PREFIX=$(date +%Y%m%d)
BUILD_SUFFIX=$(printf "%02d" $((GITHUB_RUN_NUMBER % 100)))
DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}"

# Final version: MAJOR.(MINOR+1).YYYYMMDDNN
NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}"

echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT
echo "Pre-release version: $NUMERIC_VERSION"

# Update package.json with the numeric version
npm version $NUMERIC_VERSION --no-git-tag-version
# Extract version from tag (remove 'v' prefix and '-pre' suffix)
TAG_NAME=${GITHUB_REF#refs/tags/v}
VERSION=${TAG_NAME%-pre}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Pre-release version: $VERSION"

- name: Setup package path
id: setup
Expand All @@ -60,10 +53,9 @@ jobs:
name: extension-${{ steps.version.outputs.version }}
path: ${{ steps.setup.outputs.packageName }}
if-no-files-found: error
retention-days: 7

publish:
name: Publish to Marketplaces
name: Publish Extension and Create Pre-Release
needs: package
uses: ./.github/workflows/publish-extension.yaml
with:
Expand All @@ -73,42 +65,3 @@ jobs:
secrets:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}

publishGH:
name: Update Latest Pre-Release
runs-on: ubuntu-22.04
needs: package
permissions:
contents: write
steps:
- uses: actions/checkout@v5

- uses: actions/download-artifact@v5
with:
name: extension-${{ needs.package.outputs.version }}

- name: Update Rolling Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete old release and tag
gh release delete latest-pre-release --cleanup-tag -y || true

# Create new release with heredoc for formatting
cat << EOF | gh release create latest-pre-release \
--target ${{ github.sha }} \
--title "Latest Pre-Release Build" \
--notes-file - \
--prerelease \
--latest=false \
${{ needs.package.outputs.packageName }}
## Latest Pre-Release: v${{ needs.package.outputs.version }}

**Build:** #${{ github.run_number }} | **Commit:** ${{ github.sha }}

## Changes
${{ github.event.head_commit.message }}

---
*This release is automatically updated with each push to main. The tag \`latest-pre-release\` always points to the most recent build.*
EOF
21 changes: 21 additions & 0 deletions .github/workflows/publish-extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,24 @@ jobs:
else
ovsx publish "./${{ inputs.packageName }}" -p ${{ secrets.OVSX_PAT }}
fi

publishGH:
name: Create GitHub ${{ inputs.isPreRelease && 'Pre-' || '' }}Release
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v5

- uses: actions/download-artifact@v5
with:
name: extension-${{ inputs.version }}

- name: Create ${{ inputs.isPreRelease && 'Pre-' || '' }}Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ inputs.isPreRelease }}
draft: true
title: "${{ inputs.isPreRelease && 'Pre-' || '' }}Release v${{ inputs.version }}"
files: ${{ inputs.packageName }}
26 changes: 2 additions & 24 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
tags:
- "v*"
- "!v*-pre"

permissions:
# Required to publish a release
Expand Down Expand Up @@ -52,10 +53,9 @@ jobs:
name: extension-${{ steps.version.outputs.version }}
path: ${{ steps.setup.outputs.packageName }}
if-no-files-found: error
retention-days: 30

publish:
name: Publish to Marketplaces
name: Publish Extension and Create Release
needs: package
uses: ./.github/workflows/publish-extension.yaml
with:
Expand All @@ -65,25 +65,3 @@ jobs:
secrets:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}

publishGH:
name: Create GitHub Release
runs-on: ubuntu-22.04
needs: package
permissions:
contents: write
steps:
- uses: actions/checkout@v5

- uses: actions/download-artifact@v5
with:
name: extension-${{ needs.package.outputs.version }}

- name: Create Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
draft: true
title: "Release v${{ needs.package.outputs.version }}"
files: ${{ needs.package.outputs.packageName }}