From 3c0e71410e79390bd0fe42d5ee0ec37fa4a47301 Mon Sep 17 00:00:00 2001 From: Andres Morey Date: Tue, 21 Jan 2025 12:11:21 +0300 Subject: [PATCH] added set-version script and modified publish workflow --- .github/workflows/publish.yml | 4 ++++ package.json | 2 +- set-version.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 set-version.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e4f45ad..3dc53a1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,6 +12,9 @@ jobs: packages: write contents: read steps: + - name: Get tag name + uses: olegtarasov/get-tag@2.1.3 + id: tagName - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: @@ -22,6 +25,7 @@ jobs: version: 9 - run: pnpm install - run: pnpm build + - run: /bin/bash set-version.sh ${{ steps.tagName.outputs.tag }} - run: pnpm publish --no-git-checks --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/package.json b/package.json index 84e7031..d2d047a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kubetail/ui", - "version": "0.1.4", + "version": "0.0.1", "type": "module", "sideEffects": false, "module": "./dist/index.js", diff --git a/set-version.sh b/set-version.sh new file mode 100644 index 0000000..fa9f8a9 --- /dev/null +++ b/set-version.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Check if a version number was provided as an argument +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign the new version number from command line arguments +NEW_VERSION=$1 + +# Path to the local package.json file +PACKAGE_JSON="./package.json" + +# Check if the local package.json file exists +if [ ! -f "$PACKAGE_JSON" ]; then + echo "Error: No package.json file found in the current directory." + exit 1 +fi + +# Update the version in the local package.json file +echo "Updating version in $PACKAGE_JSON to $NEW_VERSION" +# Portable handling of in-place editing with sed +sed -i.bak -E "s/\"version\": \".*\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_JSON" && rm "$PACKAGE_JSON.bak" + +echo "Version update completed."