From e3ce3833406990d472764bb49da50af75588f5de Mon Sep 17 00:00:00 2001 From: DiegoSalas27 Date: Tue, 18 Nov 2025 16:22:54 -0800 Subject: [PATCH] feat: add ci/cd --- .github/workflows/pull-request.yml | 33 ++++++++++++++++++++ .github/workflows/release.yml | 50 ++++++++++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 84 insertions(+) create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..3fbdc0c --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,33 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Pull request CI + +on: [pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Ensures full Git history is available + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies and build + run: | + npm ci + npm run build --if-present + + - name: Run unit and integration tests + run: npm run test:ci \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..40b1e56 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release +on: + push: + branches: + - main + release: + types: [published] +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Ensures full Git history is available + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Generate changelog + id: changelog + uses: TriPSs/conventional-changelog-action@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: create release + uses: actions/create-release@v1 + if: ${{ steps.changelog.outputs.skipped == 'false' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.changelog.outputs.tag }} + release_name: ${{ steps.changelog.outputs.tag }} + body: ${{ steps.changelog.outputs.clean_changelog }} + + - name: Build package + if: ${{ steps.changelog.outputs.skipped == 'false' }} + run: npm run build --if-present + + - name: Publish to npm + if: ${{ steps.changelog.outputs.skipped == 'false' }} + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index d2e2898..3d5f1ac 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist examples/**/*/package-lock.json coverage coffeeless-validator* +.vscode \ No newline at end of file