Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: Publish the built VSIX packages to the VS Code Marketplace
type: boolean
default: false
publish_open_vsx:
description: Publish the built VSIX packages to the Open VSX Registry
type: boolean
default: false

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
Expand Down Expand Up @@ -45,16 +49,82 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Restore sidecar from previous release
id: restore-sidecar
shell: bash
env:
TARGET: ${{ matrix.target }}
GH_TOKEN: ${{ github.token }}
run: |
set -eu
restored=false
trap 'echo "restored=${restored}" >> "$GITHUB_OUTPUT"' EXIT

if ! command -v gh >/dev/null || ! command -v unzip >/dev/null; then
echo "gh or unzip is unavailable; building sidecar."
exit 0
fi

git fetch --force --tags --quiet

current_tag="${GITHUB_REF_NAME}"
if [[ "${GITHUB_REF_TYPE:-}" != "tag" ]]; then
current_tag=""
fi
previous_tag="$(gh release list --exclude-drafts --exclude-pre-releases --limit 30 --json tagName --jq '.[].tagName' | awk -v current="${current_tag}" '$0 != current { print; exit }')"
if [[ -z "${previous_tag}" ]]; then
echo "No previous published release found; building sidecar."
exit 0
fi

sidecar_inputs=(sidecar/pty-host scripts/build-sidecar.js scripts/sidecar-targets.js)
if [[ "${TARGET}" == win32-* ]]; then
sidecar_inputs+=(images/Rlogo.ico)
fi
if ! git diff --quiet "${previous_tag}" HEAD -- "${sidecar_inputs[@]}"; then
echo "Sidecar build inputs changed; building sidecar."
exit 0
fi

rm -rf .restore-sidecar
mkdir -p .restore-sidecar bundled/bin
if ! gh release download "${previous_tag}" --pattern "*-${TARGET}.vsix" --dir .restore-sidecar --clobber; then
echo "Previous release ${previous_tag} has no VSIX for ${TARGET}; building sidecar."
exit 0
fi

vsix="$(find .restore-sidecar -type f -name "*-${TARGET}.vsix" | head -n 1)"
executable="R_CONSOLE_HOST"
if [[ "${TARGET}" == win32-* ]]; then
executable="R_CONSOLE_HOST.exe"
fi

if [[ -z "${vsix}" ]] || ! unzip -p "${vsix}" "extension/bundled/bin/${executable}" > "bundled/bin/${executable}"; then
rm -f "bundled/bin/${executable}"
echo "Could not extract ${executable} from ${previous_tag} VSIX; building sidecar."
exit 0
fi
if [[ "${executable}" != *.exe ]]; then
chmod 755 "bundled/bin/${executable}"
fi

echo "Restored bundled/bin/${executable} from ${previous_tag}/$(basename "${vsix}")."
restored=true

- name: Setup Rust
if: steps.restore-sidecar.outputs.restored != 'true'
uses: dtolnay/rust-toolchain@stable

- name: Install Rust target
if: steps.restore-sidecar.outputs.restored != 'true'
run: rustup target add ${{ matrix.rust_target }}

- name: Install dependencies
Expand All @@ -64,11 +134,19 @@ jobs:
run: npm run package:extension

- name: Build sidecar
if: steps.restore-sidecar.outputs.restored != 'true'
run: node scripts/build-sidecar.js --target ${{ matrix.target }}

- name: Stage sidecar
if: steps.restore-sidecar.outputs.restored != 'true'
run: node scripts/stage-sidecar.js --target ${{ matrix.target }}

- name: Verify bundled sidecar
env:
TARGET: ${{ matrix.target }}
run: |
node -e "const fs=require('fs'); const expected=process.env.TARGET.startsWith('win32-')?'R_CONSOLE_HOST.exe':'R_CONSOLE_HOST'; const dir='bundled/bin'; const files=fs.readdirSync(dir,{withFileTypes:true}).filter(e=>e.isFile()).map(e=>e.name).sort(); if(files.length!==1||files[0]!==expected){throw new Error('Expected exactly one bundled sidecar (' + expected + ') in ' + dir + '; found: ' + files.join(', '));} console.log(dir + '/' + files[0]);"

- name: Package extension
run: node scripts/package-vsix.js --target ${{ matrix.target }}

Expand Down Expand Up @@ -179,3 +257,34 @@ jobs:

- name: Publish VS Code Marketplace
run: npx @vscode/vsce publish --pat ${{ secrets.VSCE_PAT }} --skip-duplicate --packagePath ./release-artifacts/*.vsix

publish-open-vsx:
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.publish_open_vsx)
needs: package
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- name: Verify tag matches package version
if: startsWith(github.ref, 'refs/tags/v')
run: |
node -e "const pkg=require('./package.json'); const tag=process.env.GITHUB_REF_NAME; const expected='v' + pkg.version; if(tag !== expected){throw new Error('Tag ' + tag + ' does not match package version ' + expected);}"

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Download VSIX artifacts
uses: actions/download-artifact@v4
with:
pattern: vsix-*
merge-multiple: true
path: release-artifacts

- name: Publish Open VSX Registry
env:
OVSX_PAT: ${{ secrets.OPEN_VSX_TOKEN }}
run: npx --yes ovsx publish --skip-duplicate --packagePath ./release-artifacts/*.vsix
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to R Console will be documented in this file.

## [0.2.5] - 2026-05-15

### Changed
- Release packaging now reuses unchanged sidecar binaries from the previous GitHub release VSIX instead of rebuilding them for every extension release.
- Release workflow now publishes the target-specific VSIX packages to the Open VSX Registry.

### Fixed
- Fixed leading blank echo after stripped R comments.

## [0.2.4] - 2026-05-13

### Fixed
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vsc-r-console",
"displayName": "R Console for VS Code",
"description": "A lightweight R console for VS Code",
"version": "0.2.4",
"version": "0.2.5",
"publisher": "RConsole",
"license": "MIT",
"icon": "images/Rlogo.png",
Expand Down
4 changes: 3 additions & 1 deletion src/Terminal/rTerminal/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,9 @@ export async function enqueueRuntimeSubmission(
}

function normalizeSubmissionBlock(code: string): string {
return stripCommentLines(code.replace(/\n+$/, "")).trimEnd();
return stripCommentLines(code.replace(/\n+$/, ""))
.replace(/^(?:[ \t]*[\r\n])+/, "")
.trimEnd();
}

async function splitSubmissionBlocks(host: RuntimeHost, code: string): Promise<string[]> {
Expand Down
Loading