diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7bd677a..a141bb0 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -26,7 +26,6 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: github-workflows fetch-depth: 0 fetch-tags: true - uses: actions/setup-node@v4 @@ -54,6 +53,7 @@ jobs: fi echo "CURRENT_PKG_VERSION=$CURRENT_PKG_VERSION" >> "$GITHUB_ENV" echo "CURRENT_TAG_VERSION=$CURRENT_TAG_VERSION" >> "$GITHUB_ENV" + echo "CURRENT_PUBLISHED_VERSION=$CURRENT_PUBLISHED_VERSION" >> "$GITHUB_ENV" echo "SEMVER_UPDATE=${{fromJSON(vars.versions).values[inputs.version]}}" >> "$GITHUB_ENV" - name: Version package run: | @@ -66,8 +66,7 @@ jobs: echo -e "Changes since ${{env.CURRENT_PKG_VERSION}}:" >> "$CHANGELOG" git log --pretty='format:%h %s' ${{env.CURRENT_TAG_VERSION}}..HEAD~1 | grep -v '.yml' | grep -v '\[devop\]' >> "$CHANGELOG" echo "" >> "$CHANGELOG" - ./scripts/show-size-changes.sh dist/* - ./scripts/show-size-changes.sh dist/* >> "$CHANGELOG" + BASE_PKG_VERSION="$CURRENT_PUBLISHED_VERSION" ./scripts/show-size-changes.sh dist/* | tee -a "$CHANGELOG" git commit --amend -F "$CHANGELOG" # Move the version tag to the new amended commit. git tag -f -m '${{env.VERSION}}' 'v${{env.VERSION}}' diff --git a/scripts/show-size-changes.sh b/scripts/show-size-changes.sh index 711c992..ca93d76 100755 --- a/scripts/show-size-changes.sh +++ b/scripts/show-size-changes.sh @@ -31,11 +31,13 @@ function calc_perc { EOF } -LAST_PKG_VERSION="$(npm version --json | python3 -c 'import json; import sys; print(json.loads(sys.stdin.read()).get("jschardet"))')" -LAST_PKG_VERSION_HASH="$(git rev-list -n 1 v$LAST_PKG_VERSION)" +if [ -z "$BASE_PKG_VERSION" ]; then + BASE_PKG_VERSION="$(npm version --json | python3 -c 'import json; import sys; print(json.loads(sys.stdin.read()).get("jschardet"))')" +fi +BASE_PKG_VERSION_HASH="$(git rev-list -n 1 v$BASE_PKG_VERSION)" -echo "Bundle size changes since v$LAST_PKG_VERSION:" -eval "git diff-index "$LAST_PKG_VERSION_HASH" $@" | { +echo "Bundle size changes since v$BASE_PKG_VERSION:" +eval "git diff-index "$BASE_PKG_VERSION_HASH" $@" | { # vars: B=before / A=after # mode: A=added / D=deleted while read maskB maskA hashB zero mode path; do