diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8385f658fd..e73abfbe55 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,12 +48,8 @@ jobs: uses: actions/checkout@v2 - name: Preinstall run: npm run prerun - - run: cd Common && npm install - - run: cd Model && npm install - - run: cd CommonServer && npm install - - run: cd CommonUI && npm install --force - name: Publish Infrastructure Agent - run: cd InfrastructureAgent && npm run publish-package + run: bash ./Scripts/NPM/PublishAllPackages.sh docker-build-accounts: runs-on: ubuntu-latest diff --git a/Scripts/NPM/PublishAllPackage.sh b/Scripts/NPM/PublishAllPackage.sh deleted file mode 100644 index de0a6b2a34..0000000000 --- a/Scripts/NPM/PublishAllPackage.sh +++ /dev/null @@ -1,32 +0,0 @@ -# Set the package name and version -package_version=$PACKAGE_VERSION - -# If no package version is provided, exit -if [ -z "$package_version" ]; then - echo "Package version is required" - exit 1 -fi - -# touch npmrc file -touch ~/.npmrc - -# Add Auth Token to npmrc file -echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc -echo "//registry.npmjs.org/:email=npm@oneuptime.com" >> ~/.npmrc - -npm version $package_version - -# Run npm install -npm install - -# Run npm compile -npm run compile - -# Publish the package -npm publish --tag latest - -# Tag the package with the specified version -npm dist-tag add $package_name@$package_version latest - -# Logout from npm -npm logout \ No newline at end of file diff --git a/Scripts/NPM/PublishAllPackages.sh b/Scripts/NPM/PublishAllPackages.sh new file mode 100644 index 0000000000..2c375d8ec4 --- /dev/null +++ b/Scripts/NPM/PublishAllPackages.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Set the package name and version +package_version=$PACKAGE_VERSION + +# If no package version is provided, exit +if [ -z "$package_version" ]; then + echo "Package version is required" + exit 1 +fi + +# touch npmrc file +touch ~/.npmrc + +# Add Auth Token to npmrc file +echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc +echo "//registry.npmjs.org/:email=npm@oneuptime.com" >> ~/.npmrc + +publish_to_npm() { + directory_name=$1 + echo "Publishing $directory_name@$package_version to npm" + cd $directory_name + npm version $package_version + + # Before npm install, replace "Common": "file:../Common" with "@oneuptime/common": "$package_version" in package.json + sed -i "s/\"Common\": \"file:..\/Common\"/\"@oneuptime\/common\": \"$package_version\"/g" package.json + + # Before npm install, replace "CommonServer": "file:../CommonServer" with "@oneuptime/common-server": "$package_version" in package.json + sed -i "s/\"CommonServer\": \"file:..\/CommonServer\"/\"@oneuptime\/common-server\": \"$package_version\"/g" package.json + + # Before npm install, replace "Model": "file:../Model" with "@oneuptime/model": "$package_version" in package.json + sed -i "s/\"Model\": \"file:..\/Model\"/\"@oneuptime\/model\": \"$package_version\"/g" package.json + + # Before npm install, replace "CommonUI": "file:../CommonUI" with "@oneuptime/common-ui": "$package_version" in package.json + sed -i "s/\"CommonUI\": \"file:..\/CommonUI\"/\"@oneuptime\/common-ui\": \"$package_version\"/g" package.json + + + npm install + npm run compile + npm publish --tag latest +} + + +publish_to_npm "Common" +publish_to_npm "Model" +publish_to_npm "CommonServer" +publish_to_npm "CommonUI" +publish_to_npm "InfrastructureAgent"