From 2bf727d8d4f424f041ba1442f6f8cdacbbd350c5 Mon Sep 17 00:00:00 2001 From: siosonel Date: Mon, 23 Oct 2023 14:33:12 -0500 Subject: [PATCH] use pre* version type based on the branch name, and do not use the commit hash in the tag, but delete/re-tag in pre* version types --- .github/workflows/CD-publish-packages.yml | 4 ++-- build/ci-version-update.sh | 27 +++++++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CD-publish-packages.yml b/.github/workflows/CD-publish-packages.yml index 9a3691fe1c..7fb5373946 100644 --- a/.github/workflows/CD-publish-packages.yml +++ b/.github/workflows/CD-publish-packages.yml @@ -4,7 +4,7 @@ on: push: branches: - publish-packages - - fake-release + - fake-publish paths-ignore: - '**.md' - '**.txt' @@ -94,7 +94,7 @@ jobs: else ./build/ci-npm-publish.sh "$UPDATED" - if [[ "$BRANCH" != "master" ]]; then + if [[ "$BRANCH" == "master" ]]; then TAG=v$(node -p "require('./package.json').version") REMOTETAG=$(git ls-remote origin refs/tags/$TAG) if [[ "$REMOTETAG" != "" ]]; then diff --git a/build/ci-version-update.sh b/build/ci-version-update.sh index ca45d35297..4df6e38316 100755 --- a/build/ci-version-update.sh +++ b/build/ci-version-update.sh @@ -19,6 +19,11 @@ elif [[ "$NOTES" == *"Fixes:"* ]]; then VERTYPE=patch fi +BRANCH=$(git rev-parse --abbrev-ref HEAD) +if [[ "$VERTYPE" != "pre"* && "$BRANCH" != "publish-"* && "$BRANCH" != "release-chain"* && "$BRANCH" != "master" ]]; then + VERTYPE="pre$VERTYPE" +fi + ########## # CONTEXT ########## @@ -35,11 +40,15 @@ fi ######################## VERSION="$(node -p "require('./package.json').version")" -if [[ "$(grep 'Unreleased' CHANGELOG.md)" == "" ]]; then - echo "No unreleased changes to publish" - exit 1 +if [[ "$VERTYPE" != "pre"* ]]; then + if [[ "$(grep 'Unreleased' CHANGELOG.md)" == "" ]]; then + echo "No unreleased changes to publish" + exit 1 + fi + + # only update the change log if the version type is not prepatch, preminor, prerelease, pre* + sed -i.bak "s|Unreleased|$VERSION|" CHANGELOG.md fi -sed -i.bak "s|Unreleased|$VERSION|" CHANGELOG.md ################# # COMMIT CHANGES @@ -47,11 +56,6 @@ sed -i.bak "s|Unreleased|$VERSION|" CHANGELOG.md npm i --package-lock-only TAG="v$VERSION" -BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [[ "$BRANCH" != "release" && "$BRANCH" != "master" ]]; then - HASH=$(git rev-parse --short HEAD) - TAG="$TAG-$HASH" -fi COMMITMSG="$TAG $UPDATED" echo "$COMMITMSG" echo "committing version change ..." @@ -59,6 +63,11 @@ git config --global user.email "PPTeam@STJUDE.ORG" git config --global user.name "PPTeam CI" git add --all git commit -m "$COMMITMSG" +if [[ "$VERTYPE" == "pre"* ]]; then + # delete existing tags that match + git tag -d $TAG &>/dev/null + git push -d origin $TAG &>/dev/null +fi git tag $TAG BRANCH=$(git rev-parse --abbrev-ref HEAD) git push origin $BRANCH