| #!/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. |
| # |
| # Official guidance is to use even Y versions to represent stable releases, and odd |
| # Y releases to represent prerelease versions. |
| # |
| # We adopt that convention here. |
| # |
| # To make minor versions easy, we adopt the following convention for Z: |
| # YYYYMMDDNN, where `YYYY` `MM` and `DD` represent the night of publish |
| # (as per Google Standard Time). `NN` represents an emergecy disambiguation |
| # number, and will be set to `00` in this script. |
| # |
| # We keep the "checked in" version as the current stable release, and |
| # auto-increment to the next unstable version in nightlies. |
| |
| 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]} |
| current_minor=${BASH_REMATCH[2]} |
| # if current is even (stable), next should be odd (nightly) |
| minor=$(( current_minor + 1 )) |
| # as per above |
| disambig=${NIGHTLY_DISAMBIGUATOR:-00} |
| patch="$(date +%Y%0m%0d)${disambig}" |
| |
| if (( minor % 2 != 1 )); then |
| echo "next nightly version didn't have an odd minor (Y) release: ${major}.${minor}.${patch}" >&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} (prerelease)..." >&2 |
| PLUGIN_OUT="$(dirname ${PLUGIN_OUT})/vscode-fuchsia-nightly.vsix" |
| npx vsce package ${major}.${minor}.${patch} --pre-release --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 |