From 17483bc03e0fb15a97183784d2e8579ba2cf208b Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 13 Mar 2024 11:20:53 +0000 Subject: [PATCH] Add publish step for Infrastructure Agent --- .github/workflows/build.yml | 14 +++++++++++++ InfrastructureAgent/package.json | 3 ++- Scripts/NPM/PublishPackage.sh | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Scripts/NPM/PublishPackage.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd3e154e29..b4bb6e1d9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,20 @@ on: jobs: + publish-infrastucture-agent: + runs-on: ubuntu-latest + env: + CI_PIPELINE_ID: ${{github.run_number}} + NPM_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} + PACKAGE_VERSION: 7.0.${{github.run_number}} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Preinstall + run: npm run prerun + - name: Publish Infrastructure Agent + run: cd InfrastructureAgent && npm run publish + docker-build-accounts: runs-on: ubuntu-latest env: diff --git a/InfrastructureAgent/package.json b/InfrastructureAgent/package.json index 5700b301ad..2376da8d9c 100644 --- a/InfrastructureAgent/package.json +++ b/InfrastructureAgent/package.json @@ -11,7 +11,8 @@ "audit": "npm audit --audit-level=low", "dep-check": "npm install -g depcheck && depcheck ./ --skip-missing=true", "test": "rm -rf build && jest --detectOpenHandles", - "coverage": "jest --detectOpenHandles --coverage" + "coverage": "jest --detectOpenHandles --coverage", + "publish": "PACKAGE_NAME=@oneuptime/infrastructure-agent && bash ../Scripts/NPM/Publish.sh" }, "author": "", "license": "ISC", diff --git a/Scripts/NPM/PublishPackage.sh b/Scripts/NPM/PublishPackage.sh new file mode 100644 index 0000000000..b3bbd7c641 --- /dev/null +++ b/Scripts/NPM/PublishPackage.sh @@ -0,0 +1,36 @@ +# Set the package name and version +package_name=$PACKAGE_NAME +package_version=$PACKAGE_VERSION + +# If no package name is provided, exit +if [ -z "$package_name" ]; then + echo "Package name is required" + exit 1 +fi + +# 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 + +# 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