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