diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c4826ca --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,59 @@ +name: Deploy to Production + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write + packages: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + - name: Install vsce + run: npm install -g @vscode/vsce + + - name: Get version from package.json + id: package + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + + - name: Package extension + run: vsce package + + - name: Publish to VS Code Marketplace + if: github.event_name == 'push' + run: vsce publish -p ${{ secrets.VSCE_PAT }} + + - name: Create GitHub Release + if: github.event_name == 'push' + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.package.outputs.version }} + name: Release v${{ steps.package.outputs.version }} + body: | + Automated release from main branch + + See [CHANGELOG.md](CHANGELOG.md) for details. + files: | + *.vsix + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 3184ab4..b483c42 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ from module.name import ( ## Documentation -- [Deployment Flow](docs/deployment-flow.md) - Guide for building, testing, and publishing the extension +- [Deployment Flow](docs/deployment-flow.md) - Guide for building, testing, and publishing the extension (includes automated deployment via GitHub Actions) - [Health Check](docs/health-check.md) - Monitoring and verification procedures for extension health ## Miscellaneous diff --git a/docs/deployment-flow.md b/docs/deployment-flow.md index 66ffb60..35f311b 100644 --- a/docs/deployment-flow.md +++ b/docs/deployment-flow.md @@ -6,6 +6,49 @@ This document describes the deployment process for the Python Path VS Code exten The Python Path extension is published to the Visual Studio Code Marketplace. The deployment flow involves building, testing, packaging, and publishing the extension. +## The Launch Trigger: Deploy to Production + +Your code is ready. You just need to push the "Start" button. + +### Automated Deployment + +The repository is configured with GitHub Actions to automatically deploy the extension to production when changes are merged to the main branch. + +**Action:** Merge your changes to the main branch on GitHub. + +**Methods:** +- Click "Merge Pull Request" in the GitHub UI +- Or use the command line: + ```bash + git checkout main + git merge your-feature-branch + git push origin main + ``` + +**Result:** This signals GitHub Actions to automatically: +1. Run all tests to ensure code quality +2. Build and package the extension +3. Publish the new version to the VS Code Marketplace +4. Create a GitHub release with the packaged `.vsix` file + +**Prerequisites for Automated Deployment:** +- The `VSCE_PAT` secret must be configured in the repository settings +- All tests must pass +- The version in `package.json` must be higher than the currently published version + +**Monitoring the Deployment:** +- Navigate to the "Actions" tab in the GitHub repository +- Find the workflow run triggered by your merge +- Monitor the deployment progress and check for any errors +- Once complete, verify the new version on the VS Code Marketplace + +**Manual Override:** +If you need to trigger the deployment workflow manually without merging to main, you can use the "workflow_dispatch" event: +- Go to Actions tab in GitHub +- Select "Deploy to Production" workflow +- Click "Run workflow" +- Choose the branch and click "Run workflow" + ## Prerequisites Before deploying, ensure you have: @@ -159,6 +202,43 @@ For automated deployments: vsce publish -p $VSCE_PAT ``` +### GitHub Actions Automated Deployment + +The repository includes a GitHub Actions workflow (`.github/workflows/deploy.yml`) that automatically deploys the extension when changes are merged to the main branch. + +**Setup Steps:** + +1. **Configure the VSCE_PAT secret:** + - Generate a Personal Access Token (PAT) from Azure DevOps with Marketplace publishing permissions + - Go to your GitHub repository > Settings > Secrets and variables > Actions + - Click "New repository secret" + - Name: `VSCE_PAT` + - Value: Your Personal Access Token + - Click "Add secret" + +2. **Workflow Triggers:** + - **Automatic:** Triggers on push to `main` branch + - **Manual:** Can be triggered manually via the Actions tab using workflow_dispatch + +3. **Workflow Steps:** + - Checks out the code + - Sets up Node.js environment + - Installs dependencies + - Runs tests + - Packages the extension + - Publishes to VS Code Marketplace + - Creates a GitHub release with the packaged `.vsix` file + +4. **Monitoring:** + - View workflow runs in the Actions tab + - Check for green checkmarks (success) or red X's (failure) + - Review logs for any errors or issues + +**Important Notes:** +- Ensure the version in `package.json` is incremented before merging to main +- All tests must pass for deployment to succeed +- The workflow will only publish if the push event occurs (not on manual workflow_dispatch without the publish step enabled) + ## Version Management ### Pre-release Versions diff --git a/package-lock.json b/package-lock.json index bae1b09..da065c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,6 +113,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha512-Ajr4IcMXq/2QmMkEmSvxqfLN5zGmJ92gHXAeOXq1OekoH2rfDNsgdDoL2f7QaRCy7G/E6TpxBVdRuNraMztGHw==", "dev": true, + "peer": true, "dependencies": { "co": "^4.6.0", "fast-deep-equal": "^1.0.0", @@ -1795,6 +1796,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha512-Ajr4IcMXq/2QmMkEmSvxqfLN5zGmJ92gHXAeOXq1OekoH2rfDNsgdDoL2f7QaRCy7G/E6TpxBVdRuNraMztGHw==", "dev": true, + "peer": true, "requires": { "co": "^4.6.0", "fast-deep-equal": "^1.0.0",