From eac8f0dcf00adcf93788b1d8f4a44dc6b4c34270 Mon Sep 17 00:00:00 2001 From: Pooyan Khanjankhani Date: Sat, 23 Sep 2023 15:15:33 +0330 Subject: [PATCH] fix ci/cd --- .github/workflows/publish.yml | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 86f0c28..6abb750 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,30 +16,24 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: npm install - - name: Get package.json version - id: get-version - run: | - echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - - - name: Get latest npm version - id: get-npm-version - run: | - echo "latest=$(npm show convconv version)" >> $GITHUB_OUTPUT - - name: Compare versions id: compare-versions run: | - echo "should-publish=$([[ $VERSION > $LATEST ]] && echo -n 'true' || echo -n 'false')" >> $GITHUB_OUTPUT + version=$(node -p "require('./package.json').version") + latest=$(npm show convconv version) - - name: Publish to npm + echo "current branch version: $version, current upstream version: $latest" + + echo "should-publish=$([[ $version > $latest ]] && echo -n 'true' || echo -n 'false')" >> $GITHUB_OUTPUT + + - run: npm publish + name: Publish to npm if: steps.compare-versions.outputs.should-publish == 'true' env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - run: | - echo "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" > ~/.npmrc - npm publish --access public + NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}