Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
target-branch: "main"
commit-message:
prefix: "fix:"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
target-branch: "main"
commit-message:
prefix: "ci:"
145 changes: 145 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Release New Version
on:
workflow_dispatch:
inputs:
version:
description: "The version to release"
required: false
default: ""

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

env:
SVU_VERSION: "3.3.3"

permissions:
contents: write
id-token: write

jobs:
build-with-latest-hapi-release:
runs-on: ubuntu-latest
steps:
- name: Import Vault Credentials
id: import-secrets
uses: spectrocloud/palette-sdk-typescript/.github/actions/vault-credentials@main

- name: Checkout
uses: actions/[email protected]
with:
token: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}

- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: "22"
cache: "npm"
registry-url: "https://npm.pkg.github.com"

- name: Setup Copywrite
uses: hashicorp/[email protected]

- name: Checkout HAPI Repository
uses: actions/[email protected]
with:
repository: spectrocloud/hapi
path: api/hapi
fetch-depth: "0"
token: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}

- name: Install dependencies
run: make install-dependencies

- name: Install Go Swagger
run: |
dir=$(mktemp -d)
download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
curl -o $dir/swagger -L'#' "$download_url"
sudo install $dir/swagger /usr/local/bin

- name: Ensure Reviewable
run: make check-diff

- name: Generate
run: make generate

- name: Test
env:
# Expires 2026-12-31. Tenant is https://palette-ai-rsch.console.spectrocloud.com/
PALETTE_API_KEY: ${{ secrets.PALETTE_API_KEY }}
run: make test

- name: Get svu
run: |
URL="https://github.com/caarlos0/svu/releases/download/v${SVU_VERSION}/svu_${SVU_VERSION}_linux_amd64.tar.gz"
wget --quiet $URL --output-document svu.tar.gz
tar -xzf svu.tar.gz
chmod +x svu
sudo mv svu /usr/local/bin/
svu --version

- id: tag
run: |
INPUT_VERSION="${{ github.event.inputs.version }}"

if [ -n "$INPUT_VERSION" ]; then
echo "Using provided version: $INPUT_VERSION"
VERSION="$INPUT_VERSION"
PREV_VERSION=$(svu current --tag.mode all)
echo "SAME_VERSION=false" >> $GITHUB_OUTPUT

# Check if the tag already exists before creating it
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists, skipping tag creation."
else
git tag "$VERSION"
git push --tags
fi
else
VERSION=$(svu next --tag.mode all)
PREV_VERSION=$(svu current --tag.mode all)

if [ "$VERSION" = "$PREV_VERSION" ]; then
echo "no new version detected"
SAME_VERSION=true
echo "SAME_VERSION=true" >> $GITHUB_OUTPUT
else
echo "new version detected"
SAME_VERSION=false
echo "SAME_VERSION=false" >> $GITHUB_OUTPUT

# Check if the tag already exists before creating it
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists, skipping tag creation."
else
git tag "$VERSION"
git push --tags
fi
fi
fi

# Strip v prefix for npm version
NPM_VERSION="${VERSION#v}"

echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "NPM_VERSION=$NPM_VERSION" >> $GITHUB_OUTPUT
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_OUTPUT

- name: Set package version
if: steps.tag.outputs.SAME_VERSION != 'true'
run: npm version ${{ steps.tag.outputs.NPM_VERSION }} --no-git-tag-version

- name: Publish to npm
if: steps.tag.outputs.SAME_VERSION != 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}

- name: Commit reviewable diff
if: steps.tag.outputs.SAME_VERSION != 'true'
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
with:
commit_message: "chore: release ${{ steps.tag.outputs.VERSION }}"
4 changes: 3 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
registry=https://registry.npmjs.org/
access=public
@spectrocloud:registry=https://npm.pkg.github.com
access=public
ignore-scripts=true
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "palette-sdk-typescript",
"name": "@spectrocloud/palette-sdk-typescript",
"version": "0.0.5",
"description": "TypeScript SDK for Spectro Cloud Palette API",
"main": "dist/palette/index.js",
"types": "dist/palette/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/spectrocloud/palette-sdk-typescript"
},
"exports": {
".": {
"import": "./dist/palette/index.js",
Expand Down