Skip to content

Commit

Permalink
fix: fix parse_version.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
wangl-cc committed Nov 28, 2023
1 parent 91b36ec commit 61aa695
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions .github/scripts/parse_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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"

0 comments on commit 61aa695

Please sign in to comment.