| #!/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} |
| |
| echo "preparing to publishing nightly..." >&2 |
| |
| # ok, so: |
| # as of the writing of this file, the vscode marketplace doesn't support semver |
| # prerelease tags (`x.y.z-word.number`), only "normal" versions (`x.y.z`), as per |
| # https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions. |
| # see publish-nightly.sh for a full explanation. |
| |
| 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 "checked-in version should be most recent stable version, and thus should have an even minor (Y) release: ${current_stable}" >&2 |
| exit 1 |
| fi |
| |
| # 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> |
| <testcase name="vsce publish" status="run" time="0"> |
| <failure message="unable to publish vsix file, see test logs"/> |
| </testcase> |
| </testsuite> |
| </testsuites> |
| EOF |
| |
| # run the packaging |
| echo "packaging as ${major}.${minor}.${patch} (stable)..." >&2 |
| PLUGIN_OUT="$(dirname ${PLUGIN_OUT})/vscode-fuchsia-stable.vsix" |
| npx vsce package ${major}.${minor}.${patch} --baseContentUrl https://fuchsia.googlesource.com/vscode-plugins/+/refs/heads/main/ --out ${PLUGIN_OUT} &>${PACKAGE_LOG_OUTPUT} --no-git-tag-version |
| |
| # update to mark that we've done this step succesfully |
| 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"/> |
| <testcase name="vsce publish" status="run" time="0"> |
| <failure message="unable to publish vsix file, see test logs"/> |
| </testcase> |
| </testsuite> |
| </testsuites> |
| EOF |
| |
| echo "publishing from ${PLUGIN_OUT}" >&2 |
| # NB(sollyross): absolutely under no circumstances set -x here (we don't want |
| # keys in logs) |
| npx vsce publish --packagePath ${PLUGIN_OUT} --pat ${PUBLISHING_KEY} |
| |
| # update to mark that we've done this step succesfully |
| 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"/> |
| <testcase name="vsce publish" status="run" time="0"/> |
| </testsuite> |
| </testsuites> |
| EOF |
| |
| echo "...done publishing!" >&2 |