cli-publish #185
This file contains hidden or 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: Build & Publish | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| repository_dispatch: | |
| types: [cli-publish] | |
| permissions: | |
| contents: write | |
| actions: read | |
| jobs: | |
| build-and-upload: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '22' | |
| - name: Install global dependencies | |
| run: | | |
| npm install -g typescript prettier eslint vsce | |
| - name: Install project dependencies | |
| run: npm install | |
| - name: Bump package version | |
| run: npm version patch --no-git-tag-version | |
| - name: Install latest testdriverai@latest | |
| run: npm install testdriverai@latest --save | |
| - name: Commit package updates | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git pull origin main | |
| git add package.json package-lock.json | |
| git commit -m "Bump version and update testdriverai@latest [skip ci]" || exit 0 | |
| git push | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build .vsix package | |
| run: npx vsce package | |
| - name: Set .vsix file path | |
| id: get_vsix | |
| run: | | |
| VERSION=$(jq -r '.version' package.json) | |
| VSIX_PATH="./testdriver-${VERSION}.vsix" | |
| if [ ! -f "$VSIX_PATH" ]; then | |
| echo "VSIX file not found at $VSIX_PATH" | |
| exit 1 | |
| fi | |
| echo "vsix_path=$VSIX_PATH" >> $GITHUB_OUTPUT | |
| - name: Publish to vsce | |
| run: npx vsce publish --pat ${{ secrets.VSCODE_PUBLISH_PAT }} | |
| - name: Extract version from package.json | |
| id: get_version | |
| run: | | |
| VERSION=$(jq -r '.version' package.json) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Upload .vsix as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vscode-extension | |
| path: ${{ steps.get_vsix.outputs.vsix_path }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| release_name: Release v${{ steps.get_version.outputs.version }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload .vsix to GitHub Release | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.get_vsix.outputs.vsix_path }} | |
| asset_name: testdriver.vsix | |
| asset_content_type: application/octet-stream | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |