test publish #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Basic CI | ||
on: | ||
push: | ||
branches: | ||
- "master" # Trigger only on pushes to the master branch | ||
pull_request: | ||
branches: | ||
- "master" # Trigger on pull requests targeting the master branch | ||
release: | ||
types: | ||
- created # Run when a new release is created | ||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest # Use Ubuntu for the runner | ||
steps: | ||
# Step 1: Checkout the code | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
# Step 2: Set up Node.js | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "16" # Specify the Node.js version | ||
# Step 3: Install dependencies | ||
- name: Install dependencies | ||
run: npm install | ||
# Step 4: Compile the project | ||
- name: Compile the project | ||
run: npm run compile | ||
publish: | ||
name: Package & Upload VSIX (Fake Publish in Fork, Real in Main) | ||
runs-on: ubuntu-latest | ||
needs: test # Ensure tests pass before publishing | ||
if: github.event_name == 'release' # Ensure it only runs on a new release | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "21" | ||
- name: Install vsce (VS Code Extension Manager) | ||
run: npm install -g @vscode/vsce | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Build Extension | ||
run: npm run compile # Change if needed | ||
# Step 5: Package the VSIX file and ensure "dist" directory exists | ||
- name: Package the VSIX file | ||
run: | | ||
mkdir -p dist # Create the dist folder if it doesn't exist | ||
vsce package -o dist/extension.vsix # Generate the VSIX file in "dist/" | ||
# Step 6: Debugging Step - List dist directory | ||
- name: Debug: List dist directory | ||
run: ls -la dist/ | ||
# Step 7: Upload VSIX file as an artifact | ||
- name: Upload VSIX Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: vscode-extension | ||
path: dist/*.vsix | ||
# Step 8: Fake Publish on Fork, Real Publish on Main | ||
- name: Fake Publish (If Fork) or Real Publish | ||
env: | ||
IS_FORK: ${{ github.repository_owner == 'hhpatel14' }} | ||
run: | | ||
echo "Checking if this is a fork..." | ||
if [ "$IS_FORK" = "true" ]; then | ||
echo "This is a fork. Running fake publish..." | ||
else | ||
echo "This is the main repo. Publishing to VS Code Marketplace..." | ||
vsce publish --pat ${{ secrets.VSCE_TOKEN }} | ||
fi |