From ebe90dcef4ecca63fd2fc4ab02e5c88416fb37a6 Mon Sep 17 00:00:00 2001 From: Rodrigo Manuel Navarro Lajous <40175251+rlajous@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:00:19 -0300 Subject: [PATCH] fix: changed workflow copy and publish script (#136) * fix: changed workflow copy and publish script * fix: changed workflow copy and publish script --- .github/workflows/npm_publish.yml | 2 +- .github/workflows/npm_publish_tag.yml | 2 +- publish-update-packages.sh | 35 ++++++++++++++------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/npm_publish.yml b/.github/workflows/npm_publish.yml index 8fa1b3ae..49cb44ed 100644 --- a/.github/workflows/npm_publish.yml +++ b/.github/workflows/npm_publish.yml @@ -6,7 +6,7 @@ on: - main jobs: - build_and_publish: + build_and_publish_production_release: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/npm_publish_tag.yml b/.github/workflows/npm_publish_tag.yml index 0dd86646..b42686b9 100644 --- a/.github/workflows/npm_publish_tag.yml +++ b/.github/workflows/npm_publish_tag.yml @@ -8,7 +8,7 @@ permissions: actions: write jobs: - build_and_publish: + build_and_publish_beta_tag: runs-on: ubuntu-latest steps: diff --git a/publish-update-packages.sh b/publish-update-packages.sh index 82543fce..8528c3a6 100644 --- a/publish-update-packages.sh +++ b/publish-update-packages.sh @@ -7,6 +7,18 @@ for pkg in "${DIRS[@]}"; do current_version=$(jq -r '.version' $pkg/package.json) remote_version=$(npm view $pkg_name version 2>/dev/null) + # Change to the directory + if ! cd "$pkg"; then + echo "Error: Unable to change to directory: packages/$pkg" + exit 1 + fi + + # Run the build command + if ! npm run build; then + echo "Error: Failed to run 'npm run build' in directory: packages/$pkg" + exit 1 + fi + # Check if the package exists remotely or if the version has changed if [ -z "$remote_version" ] || [ "$current_version" != "$remote_version" ]; then if [ -z "$remote_version" ]; then @@ -15,30 +27,19 @@ for pkg in "${DIRS[@]}"; do echo "Detected version change in $pkg: $remote_version -> $current_version" fi - # Change to the directory - if ! cd "$pkg"; then - echo "Error: Unable to change to directory: packages/$pkg" - exit 1 - fi - - # Run the build command - if ! npm run build; then - echo "Error: Failed to run 'npm run build' in directory: packages/$pkg" - exit 1 - fi - # Run the publish command if ! npm publish --access public; then echo "Error: Failed to run 'npm publish --access public' in directory: packages/$pkg" exit 1 fi - # Change back to the original directory - if ! cd - > /dev/null; then - echo "Error: Unable to change back to original directory" - exit 1 - fi else echo "No version change detected in $pkg" fi + + # Change back to the original directory + if ! cd - > /dev/null; then + echo "Error: Unable to change back to original directory" + exit 1 + fi done