blob: a71814d24e2f90ac8f032fb6a653affe7f7441c6 [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -eo pipefail
ci_dir="$(dirname -- "${BASH_SOURCE[0]}")"
source ${ci_dir:?unable to figure out script dir}/common.sh
cd ${root_dir:?unable to find root dir}
# ensure that we're packaged
echo "ensuring that we can build final VSCode plugin package..." >&2
# pre-write, assuming we fail
cat >${PACKAGE_XML_OUTPUT} <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="" tests="1" failures="1" errors="0" time="0">
<testsuite name="vsce" tests="1" failures="1" errors="0" time="0">
<testcase name="vsce package" status="run" time="0">
<failure message="unable to build vsix file, see test logs"/>
</testcase>
</testsuite>
</testsuites>
EOF
# run the test
current_stable=$(npm version --json | jq --raw-output '."vscode-fuchsia"')
if [[ ! "${current_stable}" =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
echo "current (stable) version was not X.Y.Z: ${current_stable}" >&2
exit 1
fi
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
patch=${BASH_REMATCH[3]}
if (( minor % 2 != 0 )); then
echo "stable version didn't have an even minor (Y) release: ${current_stable}" >&2
exit 1
fi
npx vsce package --baseContentUrl https://fuchsia.googlesource.com/vscode-plugins/+/refs/heads/main/ --out ${PLUGIN_OUT} &>${PACKAGE_LOG_OUTPUT} --no-git-tag-version
# write success output if we passed!
cat >${PACKAGE_XML_OUTPUT} <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="" tests="1" failures="0" errors="0" time="0">
<testsuite name="vsce" tests="1" failures="0" errors="0" time="0">
<testcase name="vsce package" status="run" time="0"/>
</testsuite>
</testsuites>
EOF
echo "...done packaging!" >&2