Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GitHub Actions workflow for building and publishing the extension #972

Merged
merged 8 commits into from
Feb 21, 2025
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
8 changes: 3 additions & 5 deletions .github/workflows/lint-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: software-mansion-labs/vscode-js-debug
path: packages/vscode-js-debug
- name: Enforce HTTPS for submodules
run: git config --global url."https://github.com/".insteadOf "[email protected]:"

- name: Setup node
uses: actions/setup-node@v4
Expand All @@ -39,7 +37,7 @@ jobs:

- name: Install node dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
run: npm i
run: npm ci

- name: Lint extension
working-directory: ${{ env.WORKING_DIRECTORY }}
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/publish-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Publish vscode-extension
on:
workflow_dispatch:
inputs:
prerelease:
description: 'Pre-release'
default: false
type: boolean
publish_macos:
description: 'macOS'
default: true
type: boolean
publish_windows:
description: 'Windows'
default: false
type: boolean
publish_linux:
description: 'Linux'
default: false
type: boolean
ref:
description: 'The branch, tag or SHA to checkout'
default: 'main'
type: string

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Set targets
id: set_targets
run: |
targets=""
if ${{ github.event.inputs.publish_macos }}; then
targets="$targets darwin-x64 darwin-arm64"
fi
if ${{ github.event.inputs.publish_windows }}; then
targets="$targets win32-x64"
fi
if ${{ github.event.inputs.publish_linux }}; then
targets="$targets linux-x64"
fi
if [ -z "$targets" ]; then
echo "No targets specified"
exit 1
fi
echo "Publishing for targets: $targets"
echo "::set-output name=targets::$targets"

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}

- name: Enforce HTTPS for submodules
run: git config --global url."https://github.com/".insteadOf "[email protected]:"

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: packages/vscode-extension/package-lock.json

- name: Change directory
run: cd packages/vscode-extension

- name: Install dependencies
run: npm ci

- name: Build and publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
id: vs_marketplace_publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target: ${{ steps.set_targets.outputs.targets }}
pat: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
preRelease: ${{ github.event.inputs.prerelease }}
registryUrl: https://marketplace.visualstudio.com

- name: Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target: ${{ steps.set_targets.outputs.targets }}
pat: ${{ secrets.OPENVSX_MARKETPLACE_TOKEN }}
preRelease: ${{ github.event.inputs.prerelease }}
extensionFile: ${{ steps.vs_marketplace_publish.outputs.vsixPath }}
8 changes: 3 additions & 5 deletions .github/workflows/typecheck-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: software-mansion-labs/vscode-js-debug
path: packages/vscode-js-debug
- name: Enforce HTTPS for submodules
run: git config --global url."https://github.com/".insteadOf "[email protected]:"

- name: Setup node
uses: actions/setup-node@v4
Expand All @@ -39,7 +37,7 @@ jobs:

- name: Install node dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
run: npm i
run: npm ci

- name: Typecheck extension
working-directory: ${{ env.WORKING_DIRECTORY }}
Expand Down
9 changes: 5 additions & 4 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,12 @@
"build:redux-devtools-ui": "rm -rf dist/redux-devtools && cp -R ../redux-devtools-expo-dev-plugin/artifacts/RadonIDE/redux-devtools dist/redux-devtools",
"build:chrome-devtools-ui": "rm -rf dist/network-devtools-frontend && cp -R ../chrome-devtools-ui/build_artifacts/RadonIDE/gen/front_end/ dist/network-devtools-frontend",
"build:third-party": "npm run build:chrome-devtools-ui && npm run build:redux-devtools-ui",
"build:extension-debug": "node ./scripts/buildExtensionCode.mjs debug && npm run build:third-party",
"build:extension-debug": "npm run fetch:third-party && node ./scripts/buildExtensionCode.mjs debug && npm run build:third-party",
"build:extension": "node ./scripts/buildExtensionCode.mjs production && npm run build:third-party",
"build:webview": "vite build --mode production && cp ./node_modules/@vscode/codicons/dist/codicon.* dist/.",
"build:sim-server-debug": "bash ./scripts/build-sim-server-debug.sh dist",
"build:sim-server": "bash ./scripts/install-sim-server-release-build.sh dist",
"build:debug": "npm run build:extension-debug && npm run build:sim-server-debug",
"build:dist": "npm run build:extension && npm run build:sim-server && npm run build:webview && npm run build:third-party-notice",
"build:dist": "npm run fetch:third-party && npm run fetch:sim-server-assets && npm run build:extension && npm run build:webview && npm run build:third-party-notice",
"build:third-party-notice": "node ./scripts/mergeThirdPartyNotices.mjs ./submodules-NOTICES.json ./dist/simulator-server-NOTICES.json ./dist/webview-NOTICES.json ./dist/extension-NOTICES.json ./ThirdPartyNotices.json",
"watch:extension": "vite",
"package": "rm -rf dist/ && npm run build:dist",
Expand All @@ -571,7 +570,9 @@
"build:tests": "tsc --project tsconfig.test.json",
"build:plugins": "bash ./scripts/install-dev-plugins.sh",
"test": "npm run build:extension && npm run build:webview && npm run build:tests && vscode-test",
"preinstall": "cd ../vscode-js-debug && git submodule update --init ./ && npm install && npm exec tsc"
"preinstall": "bash ./scripts/init-submodules-if-not-present.sh ../vscode-js-debug && cd ../vscode-js-debug && npm i && npm exec tsc",
"fetch:sim-server-assets": "bash ./scripts/download-sim-server-release-assets.sh dist",
"fetch:third-party": "bash ./scripts/init-submodules-if-not-present.sh ../chrome-devtools-ui ../redux-devtools-expo-dev-plugin"
},
"devDependencies": {
"@babel/preset-react": "^7.23.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# This script downloads pre-built signed release versions of the simulator-server
# along with third party licenses and places them in the build location for packaging.

set -e

# execute this from the vscode-extension package directory
cd "$(dirname "$0")/.."

# take output directory from first argument or default to out - relative to the vscode-extension package location
output_dir="${1:-out}"

# second argument is the tag of the simulator-server release to download, set to latest if not provided
if [ -z "$2" ]; then
sim_server_tag=$(gh release list --json name,isLatest --jq '.[] | select(.isLatest)|.name' -R software-mansion-labs/simulator-server-releases)
echo "No tag provided, using latest release: $sim_server_tag"
else
sim_server_tag="$2"
fi

# Create the target directory if it doesn't exist
mkdir -p "$output_dir"

echo "Downloading simulator-server assets for tag $sim_server_tag"

# Download simulator-server binaries using gh CLI and place them in the output directory with correct file mode
gh release download "$sim_server_tag" --clobber -R software-mansion-labs/simulator-server-releases -p "simulator-server*" -D "$output_dir"
chmod +x "$output_dir"/simulator-server*

# Download Third Party Notices file for simulator-server
gh release download "$sim_server_tag" --clobber -R software-mansion-labs/simulator-server-releases -p "THIRDPARTY.json" -O "$output_dir/simulator-server-NOTICES.json"

echo "Successfully downloaded simulator-server assets for tag $sim_server_tag"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Accepts multiple submodules, initializing them if they are empty.

for dir in "$@"; do
if [ -z "$(ls -A "$dir")" ]; then
echo "Submodule $(basename "$dir") is empty. Initializing..."
git submodule update --init "$dir"
else
echo "Submodule $(basename "$dir") is not empty. Skipping initialization."
fi
done

This file was deleted.