diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d9d35e..dc1b38c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,43 +3,39 @@ name: Basic CI on: push: branches: - - "master" # Trigger only on pushes to the master branch + - "master" pull_request: branches: - - "master" # Trigger on pull requests targeting the master branch + - "master" release: types: - - created # Run when a new release is created + - created jobs: test: name: Run Tests - runs-on: ubuntu-latest # Use Ubuntu for the runner + runs-on: ubuntu-latest 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 + node-version: "16" - # Step 3: Install dependencies - name: Install dependencies run: npm install - # Step 4: Compile the project - name: Compile the project - run: npm run compile + 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 + needs: test + if: github.event_name == 'release' steps: - name: Checkout Repository @@ -57,32 +53,23 @@ jobs: run: npm install - name: Build Extension - run: npm run compile # Change if needed + run: npm run compile - # 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/" + - name: Ensure dist directory exists + run: mkdir -p dist - # Step 6: Debugging Step - List dist directory - - name: Debug: List dist directory - run: ls -la dist/ + - name: Package the VSIX file + run: vsce package -o dist/extension.vsix - # 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 + if [ "${{ github.repository_owner }}" = "hhpatel14" ]; then echo "This is a fork. Running fake publish..." else echo "This is the main repo. Publishing to VS Code Marketplace..."