diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cef50e5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run build diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..006b749 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,35 @@ +name: Deploy and Publish to npmjs + +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + registry-url: https://registry.npmjs.org + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run build + + - name: Publish to npmjs + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 9dafab2..d0d5c07 100644 --- a/README.md +++ b/README.md @@ -90,3 +90,21 @@ const result = await ixc.delete("cliente", { id: "123" }); Os endpoints/tabelas e payloads dependem da documentação oficial do IXC Soft: https://wikiapiprovedor.ixcsoft.com.br/# + +## Publicação automática no npmjs (GitHub Actions) + +Foi adicionado workflow em `.github/workflows/publish-npm.yml`. + +### Como configurar + +1. No GitHub do repositório, configure o secret: + - `NPM_TOKEN`: token de automação do npmjs com permissão de publish. +2. Faça commit com versão atualizada no `package.json`. +3. Crie e envie uma tag semântica: + +```bash +git tag v1.1.1 +git push origin v1.1.1 +``` + +Ao subir a tag `v*.*.*`, o workflow executa `npm ci`, `npm run build` e `npm publish`.