Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
102 changes: 102 additions & 0 deletions .github/GITHUB_ACTIONS_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# GitHub Actions Setup Guide

This repository includes automated CI/CD workflows for building and publishing the VS Code extension.

## Workflows Created

### 1. **Publish Extension** (`.github/workflows/publish-extension.yml`)
- **Triggers**: Push to `master` or `main` branch
- **Actions**:
- Builds extension
- Creates GitHub release with VSIX file
- Publishes to VS Code Marketplace (if token provided)

### 2. **Version Bump** (`.github/workflows/version-bump.yml`)
- **Triggers**: Manual workflow dispatch
- **Actions**:
- Bumps version (patch/minor/major)
- Commits changes and creates git tag
- Triggers publish workflow automatically

### 3. **Test Build** (`.github/workflows/test-build.yml`)
- **Triggers**: Pull requests and feature branches
- **Actions**:
- Tests compilation
- Builds test VSIX package
- Uploads as artifact for review

## Setup Instructions

### Step 1: Repository Secrets

Go to your GitHub repository → **Settings** → **Secrets and variables** → **Actions**

Add these repository secrets:

#### Required for Marketplace Publishing:
- **Name**: `VSCE_TOKEN`
- **Value**: Your VS Code Marketplace Personal Access Token
- **How to get**:
1. Go to [VS Marketplace Publisher Management](https://marketplace.visualstudio.com/manage)
2. Click your publisher name → **User settings** → **Personal access tokens**
3. Create token with **Marketplace (publish)** scope
4. Copy the token value

### Step 2: Enable Actions

1. Go to repository → **Actions** tab
2. Enable workflows if prompted
3. All workflows should now be visible

### Step 3: Test the Setup

#### Option A: Manual Version Bump
1. Go to **Actions** tab → **Auto Version Bump** workflow
2. Click **Run workflow** → Select version type → **Run workflow**
3. This will bump version and trigger the publish workflow

#### Option B: Direct Push
1. Make any change to code
2. Push to `master`/`main` branch
3. Watch the **Build and Publish** workflow run

## Workflow Behavior

### Without VSCE_TOKEN:
- ✅ Builds extension
- ✅ Creates GitHub release
- ✅ Uploads VSIX file
- ⚠️ Skips marketplace publishing

### With VSCE_TOKEN:
- ✅ Builds extension
- ✅ Creates GitHub release
- ✅ Uploads VSIX file
- ✅ Publishes to VS Code Marketplace

## Manual Release Process

If you prefer manual control:

1. **Bump version manually**:
```bash
npm version patch # or minor/major
git push && git push --tags
```

2. **Trigger publish workflow**:
- Push to master branch, or
- Go to Actions → **Build and Publish** → **Run workflow**

## Monitoring

- **Action status**: Check the **Actions** tab for workflow runs
- **Releases**: Check **Releases** section for created releases
- **Marketplace**: Check [VS Code Marketplace](https://marketplace.visualstudio.com/manage) for published extensions

## Troubleshooting

- **Build fails**: Check Node.js version compatibility
- **Publish fails**: Verify VSCE_TOKEN is valid and has correct permissions
- **Version conflicts**: Ensure version numbers are properly incremented
- **Missing files**: Check `.vscodeignore` for excluded files
106 changes: 106 additions & 0 deletions .github/workflows/publish-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Build and Publish VS Code Extension

on:
push:
branches: [ master, main ]
workflow_dispatch: # Allows manual triggering

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: |
# Install dependencies for the extension only
cd winccoa-vscode-extension
npm install
npm run compile

- name: Install VSCE
run: npm install -g @vscode/vsce@2.22.0

- name: Package extension
run: |
cd winccoa-vscode-extension
mkdir -p releases
# Debug: Check Node.js and VSCE versions
node --version
vsce --version
# Package from extension directory
echo "Packaging extension..."
vsce package --out releases/ || (echo "VSCE package failed, trying with --no-dependencies" && vsce package --no-dependencies --out releases/)

- name: Get current version
id: get_version
run: |
cd winccoa-vscode-extension
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Current version: $VERSION"

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
body: |
## WinCC OA Data Model LSP v${{ steps.get_version.outputs.version }}

### Installation
1. Download the `.vsix` file from this release
2. Install in VS Code: `Extensions > Install from VSIX...`
3. Clone and build language server:
```bash
git clone https://github.com/winccoa/winccoa-vscode-plugin.git
cd winccoa-vscode-plugin/winccoa-languageserver
npm install && npm run compile
```

### Changes
- Automated build and release
- Latest language server improvements

See [README.md](README.md) for full setup instructions.
draft: false
prerelease: false

- name: Upload VSIX to GitHub Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: winccoa-vscode-extension/releases/winccoa-oa-lsp-client-${{ steps.get_version.outputs.version }}.vsix
asset_name: winccoa-oa-lsp-client-${{ steps.get_version.outputs.version }}.vsix
asset_content_type: application/zip

- name: Publish to VS Code Marketplace
if: env.VSCE_TOKEN != ''
env:
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}
run: |
cd winccoa-vscode-extension
echo "Publishing to VS Code Marketplace..."
vsce publish --pat $VSCE_TOKEN

- name: Marketplace publish status
run: |
if [ -z "${{ secrets.VSCE_TOKEN }}" ]; then
echo "⚠️ VSCE_TOKEN not set - skipped marketplace publishing"
echo "💡 Add your marketplace token as a repository secret to enable automatic publishing"
echo "📦 Extension packaged and available in GitHub releases"
else
echo "✅ Extension published to VS Code Marketplace"
fi
54 changes: 54 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test Extension Build

on:
pull_request:
branches: [ master, main ]
push:
branches-ignore: [ master, main ]

jobs:
test-build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: |
# Install dependencies for the extension only
cd winccoa-vscode-extension
npm install

- name: Compile TypeScript (Extension only)
run: |
# Only compile the extension, skip language server due to winccoa-manager dependency
cd winccoa-vscode-extension
npm run compile

- name: Install VSCE
run: npm install -g @vscode/vsce@2.22.0

- name: Test package build
run: |
cd winccoa-vscode-extension
mkdir -p test-releases
# Debug: Check Node.js and VSCE versions
node --version
vsce --version
# Package from extension directory
echo "Packaging extension..."
vsce package --out test-releases/ || (echo "VSCE package failed, trying with --no-dependencies" && vsce package --no-dependencies --out test-releases/)
ls -la test-releases/

- name: Upload test package
uses: actions/upload-artifact@v4
with:
name: test-vsix-package
path: winccoa-vscode-extension/test-releases/*.vsix
retention-days: 7
56 changes: 56 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Auto Version Bump

on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major

jobs:
version-bump:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Bump version
run: |
npm version ${{ github.event.inputs.version_type }} --no-git-tag-version

- name: Get new version
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "New version: $VERSION"

- name: Commit version bump
run: |
git add package.json
git commit -m "Bump version to v${{ steps.get_version.outputs.version }}"
git push

- name: Create version tag
run: |
git tag v${{ steps.get_version.outputs.version }}
git push origin v${{ steps.get_version.outputs.version }}
31 changes: 31 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Ignore language server folder (not part of extension)
winccoa-languageserver/**

# Development files
.vscode/**
.vscode-test/**
src/**
**/*.map
.gitignore
.gitattributes
.nyc_output
coverage/
**/tsconfig*.json
**/.eslintrc.json
**/tslint.json
**/*.tsbuildinfo

# Dependencies
**/node_modules/**

# Build files
build.cmd
expiredCert.ps1

# Documentation
ICON_README.md
original_package.json

# OS files
.DS_Store
Thumbs.db
3 changes: 0 additions & 3 deletions build.cmd

This file was deleted.

Loading