publish.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. name: "Publish Release"
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. release-type:
  6. description: "Choose release type (release or pre-release)"
  7. required: true
  8. default: "release"
  9. type: choice
  10. options:
  11. - pre-release
  12. - release
  13. tag:
  14. description: "Enter existing tag to publish (e.g., v3.1.2)"
  15. required: true
  16. type: string
  17. permissions:
  18. contents: write
  19. packages: write
  20. checks: write
  21. pull-requests: write
  22. jobs:
  23. test:
  24. uses: ./.github/workflows/test.yml
  25. publish:
  26. needs: test
  27. name: Publish Extension
  28. runs-on: ubuntu-latest
  29. environment: publish
  30. steps:
  31. - uses: actions/checkout@v4
  32. with:
  33. ref: ${{ github.event.inputs.tag }}
  34. fetch-depth: 0
  35. fetch-tags: true
  36. - name: Setup Node.js
  37. uses: actions/setup-node@v4
  38. with:
  39. node-version: "lts/*"
  40. # Cache root dependencies - only reuse if package-lock.json exactly matches
  41. - name: Cache root dependencies
  42. uses: actions/cache@v4
  43. id: root-cache
  44. with:
  45. path: node_modules
  46. key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
  47. # Cache webview-ui dependencies - only reuse if package-lock.json exactly matches
  48. - name: Cache webview-ui dependencies
  49. uses: actions/cache@v4
  50. id: webview-cache
  51. with:
  52. path: webview-ui/node_modules
  53. key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }}
  54. - name: Install root dependencies
  55. if: steps.root-cache.outputs.cache-hit != 'true'
  56. run: npm install --include=optional
  57. - name: Install webview-ui dependencies
  58. if: steps.webview-cache.outputs.cache-hit != 'true'
  59. run: cd webview-ui && npm install --include=optional
  60. - name: Install Publishing Tools
  61. run: npm install -g @vscode/vsce ovsx
  62. - name: Get Version
  63. id: get_version
  64. run: |
  65. VERSION=$(node -p "require('./package.json').version")
  66. echo "version=$VERSION" >> $GITHUB_OUTPUT
  67. - name: Validate Tag
  68. id: validate_tag
  69. run: |
  70. TAG="${{ github.event.inputs.tag }}"
  71. echo "tag=$TAG" >> $GITHUB_OUTPUT
  72. echo "Using existing tag: $TAG"
  73. # Verify the tag exists
  74. if ! git rev-parse "$TAG" >/dev/null 2>&1; then
  75. echo "Error: Tag '$TAG' does not exist in the repository"
  76. exit 1
  77. fi
  78. echo "Tag '$TAG' validated successfully"
  79. - name: Package and Publish Extension
  80. env:
  81. VSCE_PAT: ${{ secrets.VSCE_PAT }}
  82. OVSX_PAT: ${{ secrets.OVSX_PAT }}
  83. CLINE_ENVIRONMENT: production
  84. TELEMETRY_SERVICE_API_KEY: ${{ secrets.TELEMETRY_SERVICE_API_KEY }}
  85. ERROR_SERVICE_API_KEY: ${{ secrets.ERROR_SERVICE_API_KEY }}
  86. # OpenTelemetry production defaults (can be overridden at runtime)
  87. OTEL_TELEMETRY_ENABLED: ${{ secrets.OTEL_TELEMETRY_ENABLED }}
  88. OTEL_LOGS_EXPORTER: otlp
  89. OTEL_METRICS_EXPORTER: otlp
  90. OTEL_EXPORTER_OTLP_PROTOCOL: ${{ secrets.OTEL_EXPORTER_OTLP_PROTOCOL }}
  91. OTEL_EXPORTER_OTLP_ENDPOINT: ${{ secrets.OTEL_EXPORTER_OTLP_ENDPOINT }}
  92. OTEL_EXPORTER_OTLP_HEADERS: ${{ secrets.OTEL_EXPORTER_OTLP_HEADERS }}
  93. run: |
  94. # Required to generate the .vsix
  95. vsce package --allow-package-secrets sendgrid --out "cline-${{ steps.get_version.outputs.version }}.vsix"
  96. if [ "${{ github.event.inputs.release-type }}" = "pre-release" ]; then
  97. npm run publish:marketplace:prerelease
  98. echo "Successfully published pre-release version ${{ steps.get_version.outputs.version }} to VS Code Marketplace and Open VSX Registry"
  99. else
  100. npm run publish:marketplace
  101. echo "Successfully published release version ${{ steps.get_version.outputs.version }} to VS Code Marketplace and Open VSX Registry"
  102. fi
  103. - name: Get Previous Tag
  104. id: prev_tag
  105. run: |
  106. CURRENT_TAG="${{ steps.validate_tag.outputs.tag }}"
  107. PREV_TAG=$(git describe --tags --abbrev=0 "$CURRENT_TAG^" 2>/dev/null || echo "")
  108. echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
  109. - name: Get Changelog Entry
  110. id: changelog
  111. run: |
  112. # Get content between first ## [ and second ## [
  113. CONTENT=$(awk '/^## \[/{if(found) exit; found=1; next} found{print}' CHANGELOG.md)
  114. echo "content<<EOF" >> $GITHUB_OUTPUT
  115. echo "$CONTENT" >> $GITHUB_OUTPUT
  116. echo "EOF" >> $GITHUB_OUTPUT
  117. - name: Create GitHub Release
  118. uses: softprops/action-gh-release@v1
  119. with:
  120. tag_name: ${{ steps.validate_tag.outputs.tag }}
  121. files: "*.vsix"
  122. body: |
  123. ${{ steps.changelog.outputs.content }}
  124. **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.prev_tag.outputs.prev_tag }}...${{ steps.validate_tag.outputs.tag }}
  125. prerelease: ${{ github.event.inputs.release-type == 'pre-release' }}
  126. env:
  127. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}