diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cfb577f..4d73103 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,127 @@ name: Manual Release on: workflow_dispatch: + inputs: + version_bump: + description: 'Select version bump type' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +permissions: + contents: write jobs: - placeholder: + # Bumps the version, tags it, and creates the baseline GitHub Release + create-release: + name: Cut Release Tag + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.version.outputs.tag }} + steps: + # generate a short-lived token from the CI app + - name: Generate GitHub App Token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + + # pass that token to checkout to authorize pushes with protection rule bypass + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} + + - name: Configure Git User + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Bump Version & Tag + id: version + working-directory: vscode-extension + run: | + git checkout ${{ github.ref_name }} + NEW_VERSION=$(npm version ${{ inputs.version_bump }} --no-git-tag-version) + echo "tag=$NEW_VERSION" >> $GITHUB_OUTPUT + + git add package.json package-lock.json + git commit -m "chore: release $NEW_VERSION" + git tag $NEW_VERSION + + - name: Push commit and tag to main + run: | + git push origin ${{ github.ref_name }} + git push origin ${{ steps.version.outputs.tag }} + + - name: Create Base GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Create an empty release container marked as latest + gh release create ${{ steps.version.outputs.tag }} \ + --title "${{ steps.version.outputs.tag }}" \ + --generate-notes \ + --latest + + # Builds and appends the VS Code Extension asset + package-vscode: + name: Build & Upload VS Code Extension + needs: create-release runs-on: ubuntu-latest + defaults: + run: + working-directory: vscode-extension steps: - - run: echo "Placeholder workflow to enable UI button." + - uses: actions/checkout@v4 + with: + ref: ${{ needs.create-release.outputs.tag }} + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: vscode-extension/package-lock.json + + - run: npm ci + - run: npm run compile + - run: npx vsce package --out vscode-extension.vsix + + # Use softprops to cleanly append the asset to the existing tag + - name: Upload VSIX to Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.create-release.outputs.tag }} + files: vscode-extension/vscode-extension.vsix + + # Builds and appends the OpenCode Plugin asset + package-opencode: + name: Build & Upload OpenCode Plugin + needs: create-release + runs-on: ubuntu-latest + defaults: + run: + working-directory: opencode-plugin + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.create-release.outputs.tag }} + + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - run: bun install + - run: bun run build + + - name: Upload OpenCode Asset to Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.create-release.outputs.tag }} + files: opencode-plugin/dist/tracybot-oc.js + diff --git a/README.md b/README.md index f4b57db..7271091 100644 --- a/README.md +++ b/README.md @@ -47,20 +47,67 @@ cd opencode-plugin bun run deploy ``` -### 3. Run the VS Code Extension +### 3. Install the VSCode Extension -There are 2 different ways of using our extension +#### Automated installation (recommended) -Option 1. Run +##### Linux & macOS +In the terminal, run ```bash -bash -c "curl -Ls -o tracy.vsix https://github.com/TracyTeam/tracybot/releases/latest/download/vscode-extension.vsix && code --install-extension tracy.vsix && rm tracy.vsix" +curl -fsSL https://raw.githubusercontent.com/TracyTeam/tracybot/main/vscode-extension/install.sh | bash ``` -Option 2. Manual install -1. Download packaged extension +##### Windows + +In Powershell, run +```powershell +powershell -Command "irm https://raw.githubusercontent.com/TracyTeam/tracybot/main/install.ps1 | iex" +``` + +#### Manual installation + +Alternatively, the extension can be installed manually. + +1. Download the packaged extension from the [latest release](https://github.com/TracyTeam/tracybot/releases/latest) +or with ```bash -bash -c "curl -Ls -o tracy.vsix https://github.com/TracyTeam/tracybot/releases/latest/download/vscode-extension.vsix" +curl -fsSL -o tracy.vsix https://github.com/TracyTeam/tracybot/releases/latest/download/vscode-extension.vsix ``` -Then open VSCode and go to EXTENSIONS (left side) --> Click on the 3 dots --> Install from vsix and choose the downloaded .vsix file + +2. In VSCode, go to `EXTENSIONS tab --> Click on the 3 dots --> Install from vsix` and choose the downloaded .vsix file + +### 4. Install the OpenCode Plugin + +If you wish to use the Tracybot OpenCode integration, the OpenCode plugin needs to be installed. + +#### From VSCode + +If the VSCode extension is installed, you will be prompted to install the plugin if it was not yet installed. +You may choose to install it globally (global OpenCode plugin directory), or per project (.opencode directory in the project). + +#### Automated Installation + +To install the plugin from the terminal, run: + +##### Linux & macOS +```bash +curl -fsSL https://raw.githubusercontent.com/TracyTeam/tracybot/main/opencode-plugin/install.sh | bash +``` + +##### Windows +```powershell +powershell -Command "irm https://raw.githubusercontent.com/TracyTeam/tracybot/main/opencode-plugin/install.sh | iex" +``` + +#### Manual Installation + +1. Download the built plugin (`tracybot-oc.js`) from the [latest release](https://github.com/TracyTeam/tracybot/releases/latest) +or with +```bash +curl -fsSL -o tracy.vsix https://github.com/TracyTeam/tracybot/releases/latest/download/tracybot-oc.js +``` + + +2. Place the downloaded file into the following directory: `$HOME/.config/opencode/plugin` diff --git a/opencode-plugin/install.ps1 b/opencode-plugin/install.ps1 new file mode 100644 index 0000000..31b0245 --- /dev/null +++ b/opencode-plugin/install.ps1 @@ -0,0 +1,28 @@ +$ErrorActionPreference = "Stop" + +$PluginDir = Join-Path $env:USERPROFILE ".config\opencode\plugin" +$DestPath = Join-Path $PluginDir "tracybot-oc.js" +$AssetUrl = "https://github.com/TracyTeam/tracybot/releases/latest/download/tracybot-oc.js" + +$TmpFile = Join-Path $env:TEMP "tracybot-oc_$(New-Guid).js" + +try { + Write-Host "Downloading latest OpenCode Tracy plugin..." + Invoke-WebRequest -Uri $AssetUrl -OutFile $TmpFile + + Write-Host "Ensuring plugin directory exists..." + if (-not (Test-Path $PluginDir)) { + New-Item -ItemType Directory -Path $PluginDir -Force | Out-Null + } + + Write-Host "Installing plugin..." + Move-Item -Path $TmpFile -Destination $DestPath -Force + + Write-Host "OpenCode Tracy plugin installed successfully!" -ForegroundColor Green +} +finally { + # 3. Guarantee temp file cleanup if execution is interrupted + if (Test-Path $TmpFile) { + Remove-Item -Path $TmpFile -Force + } +} diff --git a/opencode-plugin/install.sh b/opencode-plugin/install.sh new file mode 100644 index 0000000..7dd8a0b --- /dev/null +++ b/opencode-plugin/install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e + +PLUGIN_DIR="$HOME/.config/opencode/plugin" +DEST_PATH="$PLUGIN_DIR/tracybot-oc.js" +ASSET_URL="https://github.com/TracyTeam/tracybot/releases/latest/download/tracybot-oc.js" + +TMP_DIR=$(mktemp -d) +TMP_FILE="$TMP_DIR/tracybot-oc.js" + +trap 'rm -rf "$TMP_DIR"' EXIT + +echo "Downloading latest OpenCode Tracy plugin..." +curl -fsSL -o "$TMP_FILE" "$ASSET_URL" + +echo "Ensuring plugin directory exists ($PLUGIN_DIR)..." +mkdir -p "$PLUGIN_DIR" + +echo "Installing plugin..." +mv -f "$TMP_FILE" "$DEST_PATH" + +echo "OpenCode Tracy plugin installed successfully!" diff --git a/vscode-extension/install.ps1 b/vscode-extension/install.ps1 new file mode 100644 index 0000000..d8bf797 --- /dev/null +++ b/vscode-extension/install.ps1 @@ -0,0 +1,19 @@ +$ErrorActionPreference = "Stop" # Exit immediately if a command fails + +$VsixPath = Join-Path $env:TEMP "tracy_extension_$(New-Guid).vsix" + +try { + Write-Host "Downloading latest Tracy extension..." + Invoke-WebRequest -Uri "https://github.com/TracyTeam/tracybot/releases/latest/download/vscode-extension.vsix" -OutFile $VsixPath + + Write-Host "Installing extension in VS Code..." + code --install-extension $VsixPath + + Write-Host "Tracy extension installed successfully!" -ForegroundColor Green +} +finally { + # 2. Guarantee cleanup happens from the Temp folder + if (Test-Path $VsixPath) { + Remove-Item -Path $VsixPath -Force + } +} diff --git a/vscode-extension/install.sh b/vscode-extension/install.sh new file mode 100644 index 0000000..80b21bf --- /dev/null +++ b/vscode-extension/install.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +TMP_DIR=$(mktemp -d) +VSIX_PATH="$TMP_DIR/tracy.vsix" + +trap 'rm -rf "$TMP_DIR"' EXIT + +echo "Downloading latest Tracy extension..." +curl -fsSL -o "$VSIX_PATH" https://github.com/TracyTeam/tracybot/releases/latest/download/vscode-extension.vsix + +echo "Installing extension in VS Code..." +code --install-extension "$VSIX_PATH" + +echo "Tracy extension installed successfully!" diff --git a/vscode-extension/package-lock.json b/vscode-extension/package-lock.json index a4f5466..1cf60cb 100644 --- a/vscode-extension/package-lock.json +++ b/vscode-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "tracybot-extension", - "version": "0.0.1", + "version": "0.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tracybot-extension", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "bleu-score": "^1.0.4", "marked": "^4.3.0", diff --git a/vscode-extension/package.json b/vscode-extension/package.json index 16e4ff3..c4ff454 100644 --- a/vscode-extension/package.json +++ b/vscode-extension/package.json @@ -2,7 +2,7 @@ "name": "tracybot-extension", "displayName": "tracybot-extension", "description": "", - "version": "0.0.1", + "version": "0.0.2", "engines": { "vscode": "^1.110.0" }, diff --git a/vscode-extension/src/pluginCheck.ts b/vscode-extension/src/pluginCheck.ts index 5302849..d82894f 100644 --- a/vscode-extension/src/pluginCheck.ts +++ b/vscode-extension/src/pluginCheck.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import { homedir } from 'os'; const PLUGIN_FILENAME = 'tracybot-oc.js'; -const PLUGIN_URL = 'https://github.com/TracyTeam/tracybot/releases/download/latest/tracybot-oc.js'; +const PLUGIN_URL = 'https://github.com/TracyTeam/tracybot/releases/latest/download/tracybot-oc.js'; const SKIP_CHECK_KEY = 'tracybot.skipPluginCheck'; const Actions = {