diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16c300f..3775841 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,22 +29,19 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Get credentials + uses: leanix/secrets-action@master + with: + secret-store-credentials: ${{ secrets.INJECTED_SECRET_STORE_CREDENTIALS }} + - name: Use Node.js uses: actions/setup-node@v4 with: - node-version-file: '.node-version' + node-version: lts/* - name: Install dependencies run: npm ci - - name: Cache npm modules - uses: actions/cache@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('npm-shrinkwrap.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: Lint run: npm run lint @@ -53,3 +50,32 @@ jobs: - name: Build run: npm run build + + release: + name: Release + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: lint-test-and-build + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get credentials + uses: leanix/secrets-action@master + with: + secret-store-credentials: ${{ secrets.INJECTED_SECRET_STORE_CREDENTIALS }} + + - name: get-package-info + id: package + uses: codex-team/action-nodejs-package-info@v1.1 + + - name: Check node versions + id: online-versions + run: | + echo "online-version=$(npm view ${{steps.package.outputs.name}}@latest version)" >> $GITHUB_OUTPUT + + - name: Print versions + run: | + echo "ONLINE VERSION: ${{ steps.online-versions.outputs.online-version}}" + echo "THIS VERSION: ${{ steps.package.outputs.version}}" diff --git a/.github/workflows/lib-release.yml b/.github/workflows/lib-release.yml deleted file mode 100644 index 7174883..0000000 --- a/.github/workflows/lib-release.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Release package - -on: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - lint-test-build-release: - name: Lint, Test, Build and Release - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop' - - steps: - - name: Get credentials - uses: leanix/secrets-action@master - with: - secret-store-credentials: ${{ secrets.INJECTED_SECRET_STORE_CREDENTIALS }} - - - uses: actions/checkout@v4 - with: - token: ${{ env.GITHUB_TOKEN }} - ref: develop - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version-file: '.node-version' - - - name: Install dependencies - run: npm ci - - - name: Cache npm modules - uses: actions/cache@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('npm-shrinkwrap.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: Lint - run: npm run lint - - - name: Test - run: npm test - - - name: Build - run: npm run build - - - name: Release library - run: | - # Set npm token for leanix user - npm set "//registry.npmjs.org/:_authToken=$NPM_TOKEN" - - # Set commit user - git config --global user.name ${{ github.actor }} - git config --global user.email '${{ github.actor }}@users.noreply.github.com' - - # Bump version - npm version --no-commit-hooks patch - - # Read version - PACKAGE_VERSION=`npx -c 'echo "$npm_package_version"'` - TAG="report-lib@$PACKAGE_VERSION" - - # Commit version - git commit -am "Release of @leanix/reporting-cli@$PACKAGE_VERSION" - - # Add tag - git tag $TAG - - # Rebase on remote version of develop & push - git pull origin develop --rebase - git push origin develop --follow-tags || - git push origin develop --follow-tags - - # Publish package - npm publish --access public