Skip to content

Commit

Permalink
[devop] Fixed a few issues in npm-publish.yml
Browse files Browse the repository at this point in the history
* The checkout was hardcoded to the github-workflows branch.
* Explicitly set the base version when calculating the bundle size changes.
  • Loading branch information
aadsm committed Mar 23, 2024
1 parent 4cd7fe5 commit b659fc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -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}}'
Expand Down
10 changes: 6 additions & 4 deletions scripts/show-size-changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b659fc4

Please sign in to comment.