1#!/usr/bin/env bash
2
3set -euo pipefail
4
5if [ -z "${GITHUB_ACTIONS-}" ]; then
6 echo "Error: This script must be run in a GitHub Actions environment"
7 exit 1
8elif [ -z "${GITHUB_REF-}" ]; then
9 # This should be the release tag 'v0.x.x'
10 echo "Error: GITHUB_REF is not set"
11 exit 1
12fi
13
14version=$(script/get-crate-version zed)
15channel=$(cat crates/zed/RELEASE_CHANNEL)
16echo "Publishing version: ${version} on release channel ${channel}"
17echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
18
19expected_tag_name=""
20case ${channel} in
21stable)
22 expected_tag_name="v${version}";;
23preview)
24 expected_tag_name="v${version}-pre";;
25*)
26 echo "can't publish a release on channel ${channel}"
27 exit 1;;
28esac
29if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
30 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
31 exit 1
32fi