|
| 1 | +name: Publish VS Code Extension |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_version: |
| 7 | + description: 'Release version (semantic versioning, e.g. 1.2.3)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +permissions: {} |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + name: Package and Publish to Marketplace |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + defaults: |
| 19 | + run: |
| 20 | + working-directory: extension |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 |
| 25 | + |
| 26 | + - name: Validate version input |
| 27 | + run: | |
| 28 | + VERSION="${{ github.event.inputs.release_version }}" |
| 29 | + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 30 | + echo "Error: '$VERSION' is not a valid semantic version (expected format: X.Y.Z)" |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | + echo "Version '$VERSION' is valid." |
| 34 | +
|
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # 6.4.0 |
| 37 | + with: |
| 38 | + node-version: 22 |
| 39 | + cache: npm |
| 40 | + cache-dependency-path: extension/package-lock.json |
| 41 | + |
| 42 | + - name: Set version in package.json |
| 43 | + run: npm version "${{ github.event.inputs.release_version }}" --no-git-tag-version |
| 44 | + |
| 45 | + - name: Install dependencies |
| 46 | + run: npm ci |
| 47 | + |
| 48 | + - name: Lint |
| 49 | + run: npm run lint |
| 50 | + |
| 51 | + - name: Build |
| 52 | + run: npm run build |
| 53 | + |
| 54 | + - name: Test |
| 55 | + run: xvfb-run -a npm run test |
| 56 | + |
| 57 | + - name: Package VSIX |
| 58 | + run: npx @vscode/vsce package --out turtle-${{ github.event.inputs.release_version }}.vsix |
| 59 | + |
| 60 | + - name: Upload VSIX artifact |
| 61 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0 |
| 62 | + with: |
| 63 | + name: turtle-vsix |
| 64 | + path: extension/turtle-${{ github.event.inputs.release_version }}.vsix |
| 65 | + if-no-files-found: error |
| 66 | + |
| 67 | + - name: Publish to VS Code Marketplace |
| 68 | + run: npx @vscode/vsce publish --pat "${{ secrets.VS_MARKETPLACE_TOKEN }}" |
| 69 | + |
| 70 | + - name: Commit version changes and push to upstream repository |
| 71 | + uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0 |
| 72 | + with: |
| 73 | + branch: ${{ env.release_branch_name }} |
| 74 | + commit_user_name: github-actions |
| 75 | + commit_user_email: github-actions@github.com |
| 76 | + commit_author: Author <actions@github.com> |
| 77 | + file_pattern: 'package.json, package-lock.json' |
| 78 | + |
| 79 | + - name: Create Github release (full) |
| 80 | + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15 |
| 81 | + with: |
| 82 | + body: "Release version ${{ env.RELEASE_VERSION }}." |
| 83 | + tag_name: v${{ env.RELEASE_VERSION }} |
| 84 | + target_commitish: ${{ env.release_branch_name }} |
| 85 | + draft: false |
| 86 | + prerelease: false |
| 87 | + files: | |
| 88 | + turtle-${{ github.event.inputs.release_version }}.vsix |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments