From a934c4e62667a4bdb0ec69e166b23bb2899c759f Mon Sep 17 00:00:00 2001 From: Raul Lugo Date: Thu, 26 Dec 2024 16:05:40 +0100 Subject: [PATCH] chore: add release pipeline --- .github/workflows/release.yaml | 50 ++++++++++++++++++++++++++++++++++ README.md | 6 ---- dnt.config.mts | 2 +- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8dfb529 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,50 @@ +name: Publish to NPM + +on: + push: + tags: + - "v*.*.*" # Matches version tags like v1.0.0, v2.3.4, etc. + +env: + DIST_FOLDER: dist + +jobs: + build-and-publish: + name: Build and Publish to NPM + runs-on: ubuntu-latest + + steps: + # 1. Checkout Repository + - name: Checkout Repository + uses: actions/checkout@v4 + + # 2. Extract Tag Version + - name: Extract Tag Version + id: tag_version + run: | + echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + echo "Extracted Tag Version: ${GITHUB_REF#refs/tags/v}" + + # 3. Install Deno + - name: Install Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x # Use the latest stable version of Deno + + # 4. Inject Version into `dnt.config.mts` + - name: Update Version in dnt.config.mts + run: | + sed -i "s/\"version\": \"\"/\"version\": \"${{ env.TAG_VERSION }}\"/" dnt.config.mts + echo "Updated version in dnt.config.mts to ${{ env.TAG_VERSION }}" + + # 5. Run build:npm + - name: Build NPM Package + run: deno task build:npm + + # 6. Publish to NPM + - name: Publish to NPM + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + cd ${{ env.DIST_FOLDER }} + npm publish --access public diff --git a/README.md b/README.md index a723ead..8b858cf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Type-safe Deno/Node.js client for validating e-Invoices against EU standards usi - [Description](#description) - [Key Features](#key-features) - [Installation](#installation) - - [Deno](#deno) - [Node.js](#nodejs) - [Usage](#usage) - [API Reference](#api-reference) @@ -32,11 +31,6 @@ Caballo Client is a modern TypeScript library for validating electronic invoices ## Installation -### Deno -```ts -import { CaballoClient } from "https://deno.land/x/caballo_client@v1.0.0/mod.ts"; -``` - ### Node.js ```bash npm install caballo-client diff --git a/dnt.config.mts b/dnt.config.mts index a95ac19..05cdead 100644 --- a/dnt.config.mts +++ b/dnt.config.mts @@ -10,7 +10,7 @@ await build({ }, package: { name: "caballo-client", - version: "1.0.1", + version: "", description: "A Deno project targeting Node.js 18+ with ESM support", license: "MIT", author: "Raul Lugo",