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
50 changes: 0 additions & 50 deletions .github/workflows/rc.yml

This file was deleted.

119 changes: 98 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,131 @@ name: Release
on:
push:
branches: [main]
workflow_dispatch: {}

permissions:
contents: write

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

jobs:
# Stable releases on push to main under npm dist-tag 'latest'.
# Pre-releases on workflow_dispatch from any non-main branch
# (X.Y.Z-rc.N) under dist-tag 'rc'. cog computes the next version
# from conventional commits, updates package.json + CHANGELOG.md,
# commits "chore(version): X.Y.Z", and tags vX.Y.Z.
release:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.semver.outputs.tag }}
released: ${{ steps.semver.outputs.released }}
tag: ${{ steps.tag.outputs.tag }}
released: ${{ steps.tag.outputs.released }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Semver Release
id: semver
uses: huggingface/semver-release-action@1a164868d29fb12acd39d70e8e47326db9d78ad2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compute bump args
id: args
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
REF="${{ github.ref_name }}"
if [[ "$REF" == "main" ]]; then
echo "Refusing to publish a prerelease from main; use a feature branch." >&2
exit 1
fi
echo "value=--auto --pre rc.${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
else
echo "value=--auto" >> "$GITHUB_OUTPUT"
fi

- name: Capture pre-bump tag
id: before
run: echo "tag=$(git describe --tags --abbrev=0 2>/dev/null || echo '')" >> "$GITHUB_OUTPUT"

- name: Bump
id: bump
uses: cocogitto/cocogitto-action@9a9fe03b31c47444290c0d7f9b1ee1b44ee13f20 # v4.1.0
continue-on-error: true
with:
command: bump
args: ${{ steps.args.outputs.value }}
git-user: github-actions[bot]
git-user-email: 41898282+github-actions[bot]@users.noreply.github.com

- name: Resolve tag + released flag
id: tag
run: |
AFTER=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [[ -z "$AFTER" || "$AFTER" == "${{ steps.before.outputs.tag }}" ]]; then
echo "released=false" >> "$GITHUB_OUTPUT"
echo "No releasable commits since '${{ steps.before.outputs.tag }}'"
else
echo "released=true" >> "$GITHUB_OUTPUT"
echo "tag=$AFTER" >> "$GITHUB_OUTPUT"
fi

- name: Push commit + tag
if: steps.tag.outputs.released == 'true'
run: |
git push origin "HEAD:${{ github.ref_name }}"
git push origin "${{ steps.tag.outputs.tag }}"

build:
needs: [release]
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 22

- run: npm ci

- name: Set version from release tag
run: npm version "${{ needs.release.outputs.tag }}" --no-git-tag-version

- run: npm run typecheck

- run: npm run build

- name: Pack tarball
run: npm pack

- name: Upload tarball to release
- name: Generate changelog for this tag
id: changelog
uses: cocogitto/cocogitto-action@9a9fe03b31c47444290c0d7f9b1ee1b44ee13f20 # v4.1.0
with:
command: changelog
args: --at ${{ needs.release.outputs.tag }}

- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TARBALL=$(ls *.tgz)
TAG="${{ needs.release.outputs.tag }}"
NOTES=$(printf 'Install with:\n```\nnpm install @hostsmith/sdk@%s\n```\n\nOr from the GitHub Release tarball:\n```\nnpm install https://github.com/%s/releases/download/%s/%s\n```' "${TAG#v}" "${{ github.repository }}" "$TAG" "$TARBALL")
gh release edit "$TAG" --notes "$NOTES"
gh release upload "$TAG" "$TARBALL"
TARBALL=$(ls *.tgz)
{
printf 'Install with:\n```\nnpm install @hostsmith/sdk@%s\n```\n\n' "${TAG#v}"
printf 'Or from the GitHub Release tarball:\n```\nnpm install https://github.com/%s/releases/download/%s/%s\n```\n\n---\n\n' "${{ github.repository }}" "$TAG" "$TARBALL"
cat <<'CHANGELOG'
${{ steps.changelog.outputs.stdout }}
CHANGELOG
} > release-notes.md
PRERELEASE=""
if [[ "$TAG" == *-* ]]; then PRERELEASE="--prerelease"; fi
gh release create "$TAG" "$TARBALL" \
$PRERELEASE \
--title "$TAG" \
--notes-file release-notes.md

# Publishes @hostsmith/sdk to npm using GitHub OIDC (npm Trusted Publisher).
# No NPM_TOKEN secret is used - authentication is via the id-token below
# plus the Trusted Publisher configuration on npmjs.com for this package.
# Stable tags (vX.Y.Z) publish under 'latest'. Prerelease tags (vX.Y.Z-*)
# publish under 'rc' so they don't override the default install target.
publish-npm:
needs: [release, build]
if: needs.release.outputs.released == 'true'
Expand All @@ -69,6 +137,8 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}

- uses: actions/setup-node@v4
with:
Expand All @@ -77,11 +147,18 @@ jobs:

- run: npm ci

- name: Set version from release tag
run: npm version "${{ needs.release.outputs.tag }}" --no-git-tag-version

- run: npm run typecheck

- run: npm run build

- run: npm publish --provenance --access public
- name: Determine npm dist-tag
id: disttag
run: |
TAG="${{ needs.release.outputs.tag }}"
if [[ "$TAG" == *-* ]]; then
echo "tag=rc" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi

- run: npm publish --provenance --access public --tag ${{ steps.disttag.outputs.tag }}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

- - -
## v0.1.0-rc.14 - 2026-05-02
#### Features
- <span style="background-color: #d73a49; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold; font-size: 0.85em;">BREAKING</span>update release workflow and trigger release - (c2d7b3d) - Gennady Potapov
- <span style="background-color: #d73a49; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold; font-size: 0.85em;">BREAKING</span>initial 1.0.0 release - (eecfc8c) - Gennady Potapov
#### Continuous Integration
- switch release flow to cocogitto - (0cc4d51) - Gennady Potapov
#### Miscellaneous Chores
- (**version**) v0.1.0-rc.13 - (4f7fe17) - github-actions[bot]

- - -

## v0.1.0-rc.13 - 2026-05-02
#### Features
- <span style="background-color: #d73a49; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold; font-size: 0.85em;">BREAKING</span>update release workflow and trigger release - (c2d7b3d) - Gennady Potapov
- <span style="background-color: #d73a49; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold; font-size: 0.85em;">BREAKING</span>initial 1.0.0 release - (eecfc8c) - Gennady Potapov
#### Continuous Integration
- switch release flow to cocogitto - (0cc4d51) - Gennady Potapov

- - -

Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
12 changes: 12 additions & 0 deletions cog.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tag_prefix = "v"

# Keep package.json version in sync with the bumped tag.
pre_bump_hooks = [
"npm version --no-git-tag-version --allow-same-version {{version}}",
]

[changelog]
path = "CHANGELOG.md"
remote = "github.com"
owner = "hostsmith"
repository = "js-sdk"
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hostsmith/sdk",
"version": "0.0.0",
"version": "0.1.0-rc.14",
"description": "Node.js SDK for the Hostsmith Public API",
"license": "MIT",
"type": "module",
Expand Down