release.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - "v*"
  6. workflow_dispatch:
  7. inputs:
  8. version:
  9. description: "Release version (e.g., v1.0.0)"
  10. required: true
  11. type: string
  12. prerelease:
  13. description: "Mark as pre-release"
  14. required: false
  15. type: boolean
  16. default: false
  17. jobs:
  18. build-release:
  19. runs-on: ubuntu-latest
  20. permissions:
  21. contents: write
  22. steps:
  23. - name: Checkout
  24. uses: actions/checkout@v4
  25. - name: Set up Bun
  26. uses: ./.github/actions/setup-bun
  27. - name: Set up pnpm
  28. uses: pnpm/action-setup@v4
  29. with:
  30. version: 9
  31. - name: Set up Node.js
  32. uses: actions/setup-node@v4
  33. with:
  34. node-version: "20"
  35. cache: "pnpm"
  36. cache-dependency-path: |
  37. hosts/vscode-plugin/pnpm-lock.yaml
  38. - name: Set up Java
  39. uses: actions/setup-java@v4
  40. with:
  41. distribution: "temurin"
  42. java-version: "21"
  43. - name: Determine version
  44. id: version
  45. run: |
  46. if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
  47. echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
  48. echo "prerelease=${{ github.event.inputs.prerelease }}" >> $GITHUB_OUTPUT
  49. else
  50. echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
  51. if [[ "${GITHUB_REF#refs/tags/}" == *"-"* ]]; then
  52. echo "prerelease=true" >> $GITHUB_OUTPUT
  53. else
  54. echo "prerelease=false" >> $GITHUB_OUTPUT
  55. fi
  56. fi
  57. - name: Build backend binaries
  58. run: ./hosts/scripts/build_opencode.sh
  59. - name: Install VSCode plugin dependencies (all)
  60. working-directory: hosts/vscode-plugin
  61. run: |
  62. if [ -f pnpm-lock.yaml ]; then
  63. pnpm install --frozen-lockfile
  64. else
  65. npm ci
  66. fi
  67. - name: Compile VSCode plugin TypeScript
  68. working-directory: hosts/vscode-plugin
  69. run: |
  70. if [ -f pnpm-lock.yaml ]; then
  71. pnpm run compile:production
  72. else
  73. npm run compile:production
  74. fi
  75. - name: Package VSCode plugin from staging (no prepublish)
  76. working-directory: hosts/vscode-plugin
  77. run: |
  78. STAGE_DIR="../tmp_opencode_vscode_stage"
  79. rm -rf "$STAGE_DIR"
  80. mkdir -p "$STAGE_DIR"
  81. # Copy minimal required files
  82. cp package.json "$STAGE_DIR/"
  83. cp -R out "$STAGE_DIR/out"
  84. cp -R resources "$STAGE_DIR/resources"
  85. [ -f README.md ] && cp README.md "$STAGE_DIR/" || true
  86. [ -f CHANGELOG.md ] && cp CHANGELOG.md "$STAGE_DIR/" || true
  87. [ -f ../../LICENSE ] && cp ../../LICENSE "$STAGE_DIR/" || true
  88. # Sanitize package.json: remove scripts and devDependencies
  89. node -e '
  90. const fs=require("fs");
  91. const path=require("path");
  92. const pkgPath=path.resolve(process.cwd(), "../tmp_opencode_vscode_stage/package.json");
  93. const pkg=JSON.parse(fs.readFileSync(pkgPath, "utf8"));
  94. delete pkg.scripts;
  95. delete pkg.devDependencies;
  96. fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
  97. '
  98. # Package from staging directory without touching dependencies
  99. ( cd "$STAGE_DIR" && npx -y @vscode/vsce package --no-dependencies --out "opencode-$(date +%Y%m%d-%H%M%S).vsix" )
  100. # Move artifact back into plugin dir for later collection
  101. mv "$STAGE_DIR"/*.vsix .
  102. # Clean up staging
  103. rm -rf "$STAGE_DIR"
  104. - name: Build JetBrains plugin distribution
  105. uses: gradle/gradle-build-action@v2
  106. with:
  107. gradle-version: 8.7
  108. arguments: buildPlugin
  109. build-root-directory: hosts/jetbrains-plugin
  110. - name: Prepare release artifacts
  111. run: |
  112. mkdir -p release-artifacts
  113. # Find and copy VSCode extension
  114. find hosts/vscode-plugin -name "*.vsix" -type f -exec cp {} release-artifacts/ \;
  115. # Find and copy JetBrains plugin
  116. find hosts/jetbrains-plugin/build/distributions -name "*.zip" -type f -exec cp {} release-artifacts/ \;
  117. # Rename artifacts with version
  118. cd release-artifacts
  119. for file in *.vsix; do
  120. if [ -f "$file" ]; then
  121. mv "$file" "opencode-vscode-${{ steps.version.outputs.version }}.vsix"
  122. fi
  123. done
  124. for file in *.zip; do
  125. if [ -f "$file" ]; then
  126. mv "$file" "opencode-jetbrains-${{ steps.version.outputs.version }}.zip"
  127. fi
  128. done
  129. ls -la
  130. - name: Create Release
  131. uses: softprops/action-gh-release@v1
  132. with:
  133. tag_name: ${{ steps.version.outputs.version }}
  134. name: OpenCode Release ${{ steps.version.outputs.version }}
  135. prerelease: ${{ steps.version.outputs.prerelease }}
  136. generate_release_notes: true
  137. files: |
  138. release-artifacts/*
  139. body: |
  140. ## OpenCode Release ${{ steps.version.outputs.version }}
  141. This release includes:
  142. - **VSCode Extension**: `opencode-vscode-${{ steps.version.outputs.version }}.vsix`
  143. - **JetBrains Plugin**: `opencode-jetbrains-${{ steps.version.outputs.version }}.zip`
  144. ### Installation Instructions
  145. #### VSCode Extension
  146. 1. Download `opencode-vscode-${{ steps.version.outputs.version }}.vsix`
  147. 2. Install using: `code --install-extension opencode-vscode-${{ steps.version.outputs.version }}.vsix`
  148. #### JetBrains Plugin
  149. 1. Download `opencode-jetbrains-${{ steps.version.outputs.version }}.zip`
  150. 2. In your JetBrains IDE, go to Settings → Plugins → Install Plugin from Disk
  151. 3. Select the downloaded zip file
  152. ### What's Changed
  153. See the auto-generated release notes below for detailed changes.
  154. test-artifacts:
  155. runs-on: ubuntu-latest
  156. needs: build-release
  157. if: always()
  158. steps:
  159. - name: Download artifacts
  160. uses: actions/download-artifact@v4
  161. with:
  162. name: release-artifacts
  163. path: ./test-artifacts
  164. continue-on-error: true
  165. - name: Verify artifacts
  166. run: |
  167. echo "Checking release artifacts..."
  168. ls -la ./test-artifacts/ || echo "No artifacts found"
  169. # Check if VSCode extension exists
  170. if ls ./test-artifacts/*.vsix 1> /dev/null 2>&1; then
  171. echo "✓ VSCode extension found"
  172. else
  173. echo "✗ VSCode extension missing"
  174. fi
  175. # Check if JetBrains plugin exists
  176. if ls ./test-artifacts/*.zip 1> /dev/null 2>&1; then
  177. echo "✓ JetBrains plugin found"
  178. else
  179. echo "✗ JetBrains plugin missing"
  180. fi