Skip to content

Commit

Permalink
build: adding github publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Jan 9, 2025
1 parent 65dc1f0 commit 436ace1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ jobs:
with:
node-version: 18.x

- name: Publish to NPM
run: ./scripts/publish.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Update RELEASES.MD
uses: vonage/[email protected]

- name: Commit release
- name: Commit release notes
run: |
git config --local user.name github-actions
git config --local user.email [email protected]
git add RELEASES.md
git commit -m "chore: updated release log"
git push --force-with-lease
git push --force-with-leaseCallUpdateResultc
10 changes: 9 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
"packages": [
"packages/*"
],
"version": "independent"
"version": "independent",
"command": {
"version": {
"message": "chore(release): publish",
"conventionalCommits": true,
"noCommitHooks": true,
"exact": true
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"format": "prettier -- -w",
"jest": "jest",
"lerna": "lerna",
"version": "lerna version --conventional-commits --no-commit-hooks --message='chore(release): publish %s'",
"version": "lerna version --conventional-commits --no-commit-hooks",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prepare": "is-ci || husky install",
Expand Down
28 changes: 28 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Enable error handling
set -e

# Run the `lerna changed` command to get the list of changed packages
changed_packages=$(npm run --silent lerna -- changed)

# Loop through each changed package
echo "$changed_packages" | while read -r package; do
# Extract the package name without the `@vonage/` prefix
package_name=${package#@vonage/}

# Change directory into the package folder and publish
if [ -d "packages/$package_name" ]; then
cd "packages/$package_name" || exit
echo "Publishing $package_name..."
if ! npm publish; then
echo "Failed to publish $package_name" >&2
exit 1
fi
cd - > /dev/null || exit # Return to the previous directory
else
echo "Directory packages/$package_name does not exist, skipping..."
fi
done

echo "Publishing process completed!"

0 comments on commit 436ace1

Please sign in to comment.