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 10, 2025
1 parent 65dc1f0 commit 6654b25
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to NPM

on:
release:
types:
- published

env:
GH_TOKEN: ${{ secrets.GH_TOKEN_COMMIT }}

jobs:
test-action:
runs-on: ubuntu-latest
name: Update Release

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: '3.x'
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_COMMIT }}

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Publish to NPM
run: ./scripts/publish.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
- 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 6654b25

Please sign in to comment.