From 61aa6952547cfd33516bb96e346d82a84a8f39df Mon Sep 17 00:00:00 2001 From: Loong Date: Tue, 28 Nov 2023 15:23:55 +0800 Subject: [PATCH] fix: fix parse_version.sh --- .github/scripts/parse_version.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/scripts/parse_version.sh b/.github/scripts/parse_version.sh index 182f3be6..30249019 100755 --- a/.github/scripts/parse_version.sh +++ b/.github/scripts/parse_version.sh @@ -6,9 +6,9 @@ CARGO_PKG_VERSION=$(yq -r '.package.version' maa-cli/Cargo.toml) if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then echo "PR detected, marking version as alpha pre-release and skipping publish" + channel="alpha" + publish="false" VERSION="$CARGO_PKG_VERSION-alpha.$(date +%s)" - echo "channel=alpha" > $GITHUB_OUTPUT - echo "publish=false" > $GITHUB_OUTPUT elif [ "$GITHUB_EVENT_NAME" == "schedule" ]; then echo "Scheduled event detected, marking version as alpha pre-release and publish to alpha channel" # check if there are some new commits @@ -17,15 +17,14 @@ elif [ "$GITHUB_EVENT_NAME" == "schedule" ]; then last_commit=$(git rev-parse HEAD) if [ "$pubulished_commit" == "$last_commit" ]; then echo "No new commits, exiting, skipping all steps" - echo "skip=true" > $GITHUB_OUTPUT + echo "skip=true" >> "$GITHUB_OUTPUT" exit 0 fi VERSION="$CARGO_PKG_VERSION-alpha.$(date +%s)" - echo "channel=$channel" > $GITHUB_OUTPUT - echo "publish=true" > $GITHUB_OUTPUT + publish="true" elif [ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]; then echo "Workflow dispatch event detected, reading inputs" - beta=$(yq -r '.inputs.beta' $GITHUB_EVENT_PATH) + beta=$(yq -r '.inputs.beta' "$GITHUB_EVENT_PATH") if [ "$beta" == "true" ]; then echo "Beta flag detected, marking version as beta pre-release and publish to beta channel" beta_number=$(yq -r ".details.beta_number" version/beta.json) @@ -35,19 +34,21 @@ elif [ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]; then echo "No beta flag detected, marking version as stable release and publish to stable channel" channel="stable" fi - publish=$(yq -r '.inputs.publish' $GITHUB_EVENT_PATH) - echo "channel=$channel" > $GITHUB_OUTPUT - echo "publish=$publish" > $GITHUB_OUTPUT + publish=$(yq -r '.inputs.publish' "$GITHUB_EVENT_PATH") else REF_VERSION=${GITHUB_REF#refs/tags/v} if [ "$REF_VERSION" == "$GITHUB_REF" ]; then - echo "Current commit is not tagged, skipping all steps" - echo "skip_all=true" > $GITHUB_OUTPUT - exit 0 + echo "Version tag not matched, aborting" + exit 1 fi echo "Tag detected, marking version as stable release and publish to stable channel" channel="stable" VERSION="$REF_VERSION" fi -echo "Release version: $VERSION" -echo "version=$VERSION" > $GITHUB_OUTPUT +echo "Release version $VERSION to $channel channel and publish=$publish" +{ + echo "channel=$channel" + echo "version=$VERSION" + echo "publish=$publish" + echo "skip=false" +} >> "$GITHUB_OUTPUT"