feat: npm CLI

This commit is contained in:
Daniel Hougaard
2024-11-12 20:36:09 +04:00
parent a55fe2b788
commit 3b02eedca6
6 changed files with 200 additions and 77 deletions

View File

@@ -1,12 +1,15 @@
name: Build and release CLI
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
push:
# run only against tags
tags:
- "infisical-cli/v*.*.*"
# push:
# run only against tags
# tags:
# - "infisical-cli/v*.*.*"
permissions:
contents: write
@@ -26,6 +29,63 @@ jobs:
CLI_TESTS_USER_PASSWORD: ${{ secrets.CLI_TESTS_USER_PASSWORD }}
CLI_TESTS_INFISICAL_VAULT_FILE_PASSPHRASE: ${{ secrets.CLI_TESTS_INFISICAL_VAULT_FILE_PASSPHRASE }}
npm-release:
runs-on: ubuntu-20.04
env:
working-directory: ./npm
CLI_VERSION: 1.1.1
needs:
- cli-integration-tests
# - goreleaser
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# - name: Extract version
# run: |
# VERSION=$(echo ${{ github.ref_name }} | sed 's/infisical-cli\/v//')
# echo "Version extracted: $VERSION"
# echo "CLI_VERSION=$VERSION" >> $GITHUB_ENV
- name: Print version
run: echo ${{ env.CLI_VERSION }}
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: 20
cache: "npm"
cache-dependency-path: ./npm/package-lock.json
- name: Install dependencies
working-directory: ${{ env.working-directory }}
run: npm install
- name: Set NPM version
working-directory: ${{ env.working-directory }}
run: npm version ${{ env.CLI_VERSION }} --allow-same-version --no-git-tag-version
- name: Setup NPM
working-directory: ${{ env.working-directory }}
run: |
echo 'registry="https://registry.npmjs.org/"' > ./.npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc
echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Pack NPM
working-directory: ${{ env.working-directory }}
run: npm pack
- name: Publish NPM
run: npm publish --tarball=./infisical-sdk-${{github.ref_name}} --access public --registry=https://registry.npmjs.org/ --dry-run
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
goreleaser:
runs-on: ubuntu-20.04
needs: [cli-integration-tests]