diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..12280d4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Publish NPM Package + +on: + push: + tags: + - 'v*' + workflow_dispatch: # Allow manual trigger + +jobs: + publish-package: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + cache-dependency-path: 'package.json' + + - name: Determine release type + id: determine-release + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then + echo "release=minor" >> $GITHUB_ENV + elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "release=patch" >> $GITHUB_ENV + else + echo "release=none" >> $GITHUB_ENV + fi + else + echo "release=none" >> $GITHUB_ENV + fi + + - name: Login to npm + if: env.release != 'none' + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org/' + node-version: '18' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + if: env.release != 'none' + run: npm publish \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..821c19d --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +.github \ No newline at end of file diff --git a/package.json b/package.json index f59655c..39c8257 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,8 @@ "version": "2.1.0", "description": "The OpenAI ChatGPT Helper Extension for Hexabot Chatbot / Agent Builder to enable the LLM Capability", "scripts": { - "release:common": "git push origin --tags && npm publish", - "release:patch": "npm version patch && npm run release:common", - "release:minor": "npm version minor && npm run release:common", - "release": "echo 'Please specify patch or minor: npm run release:patch or npm run release:minor'" + "release:patch": "npm version patch && git push origin main --tags", + "release:minor": "npm version minor && git push origin main --tags" }, "dependencies": { "openai": "^4.54.0"