Skip to content

fix: fixes and refinements to the httpclient #2063

fix: fixes and refinements to the httpclient

fix: fixes and refinements to the httpclient #2063

Workflow file for this run

name: Build, Test and Publish
on:
merge_group:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
env:
TARGET_NODE_VERSION: '24.x'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, 24.x, 25.x]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
scope: "@openfga"
always-auth: false
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.TARGET_NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Check for circular dependencies
run: npx madge --circular . --extensions ts,js
- name: Run tests
run: npm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: openfga/js-sdk
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.TARGET_NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Audit dependencies
run: npm audit
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, test, audit]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
scope: "@openfga"
always-auth: false
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Validate tag and determine npm tag
id: npm-tag
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Validate tag format
if [[ ! "$TAG" =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-(alpha|beta|rc)\.[[:digit:]]+)?$ ]]; then
echo "Error: Tag '$TAG' does not match the required format"
echo "Valid formats:"
echo " - v1.2.3"
echo " - v1.2.3-alpha.1"
echo " - v1.2.3-beta.1"
echo " - v1.2.3-rc.1"
exit 1
fi
# Determine npm tag
VERSION="${TAG#v}"
if [[ "$VERSION" =~ -alpha ]]; then
echo "tag=alpha" >> $GITHUB_OUTPUT
elif [[ "$VERSION" =~ -beta ]]; then
echo "tag=beta" >> $GITHUB_OUTPUT
elif [[ "$VERSION" =~ -rc ]]; then
echo "tag=rc" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
run: npx -y npm@11.9.0 publish --tag ${{ steps.npm-tag.outputs.tag }}
create-release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
prerelease_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+-(alpha|beta|rc)\.[[:digit:]]+$
changelog_file: CHANGELOG.md
create_draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}