Skip to content

Commit

Permalink
Let the release build use signed prebuilds from sim-server repo (#606)
Browse files Browse the repository at this point in the history
This PR changes the build script we use for simulator server release
builds.

Since in the sim-server repo we have automated action that generates
properly built and signed binaries, we should use that instead of
building release version locally (especially that we need binaries for
all the platforms).

The new script uses github CLI to download the pre-built binaries from
sim-server repo releases, and to work requires that github CLI is
installed and authenticated with an account that has access to the repo.

The script also verifies that the binaries we use for sim-server are
from a tagged version. We do that by checking the tag of sim-server
submodule. This way we get the tag for the release from which we should
download the binaries.

As a consequence, the release builds of the extension can only use a
tagged version of the sim-server (which is good, as would let as keep
better track of the updates done between the two repos).

## Test plan
1. Make release build, make sure it runs ok
  • Loading branch information
kmagiera authored Oct 11, 2024
1 parent 415e606 commit 0c21812
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
"build:expo-fingerprint": "esbuild ./node_modules/@expo/fingerprint/build/sourcer/ExpoConfigLoader.js --bundle --format=cjs --outfile=dist/ExpoConfigLoader.js --platform=node --minify",
"build:webview": "vite build --mode production && cp ./node_modules/@vscode/codicons/dist/codicon.* dist/.",
"build:sim-server-debug": "bash ./scripts/build-sim-server.sh dist Debug",
"build:sim-server": "bash ./scripts/build-sim-server.sh dist Release",
"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",
"watch:extension": "vite",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# This script uses the GitHub CLI to download pre-built signed release versions
# of the simulator-server binaries and places them in the build location for packaging.
# In order to use this script you need to have GitHub CLI installed and authenticated
# with the access to the simulator-server repo.

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}"

submodule_status=$(git submodule status ../simulator-server)
if [[ $submodule_status == -* ]]; then # submodule is not initialized
echo "Submodule is not initialized"
exit 1
fi

# For release builds we always make sure that submodule is up to date
git submodule update --init -- ../simulator-server

submodule_status=$(git submodule status ../simulator-server)
if [[ $submodule_status == +* ]]; then # submodule is not up-to-date
echo "Submodule is not up to date"
exit 1
fi

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

# Get tag of simulator-server submodule
sim_server_tag=$(git -C ../simulator-server describe --tags)

echo "Downloading sim-server binaries for tag $sim_server_tag"

# Download Mac and Windows binaries using gh CLI and place them in the correcto location
mac_binary_path="$output_dir/sim-server"
gh release download $sim_server_tag -R software-mansion-labs/simulator-server -p simulator-server -O "$mac_binary_path"
chmod +x "$mac_binary_path"

win_binary_path="$output_dir/sim-server-executable.exe"
gh release download $sim_server_tag -R software-mansion-labs/simulator-server -p simulator-server.exe -O "$win_binary_path"
chmod +x "$win_binary_path"

0 comments on commit 0c21812

Please sign in to comment.