Skip to content
Open
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
11 changes: 4 additions & 7 deletions .github/workflows/publish-cdn.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Publish to CDN
on:
workflow_dispatch:
inputs:
version:
description: 'Release tag'
required: true
release:
types: [published]

jobs:
publish:
Expand All @@ -16,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.version }}
ref: ${{ github.ref }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -28,4 +25,4 @@ jobs:
with:
node-version: 20.x
- run: npm ci
- run: node scripts/cdn_deploy.js --skipCheckout --tag=${{ github.event.inputs.version }}
- run: node scripts/cdn_deploy.js --skipCheckout --tag=${{ github.ref_name }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Confirm expected tag format for cdn_deploy.js.

You’re now passing github.ref_name (e.g., “v1.2.3”). If the script expects “1.2.3” (no “v”), it will mispublish.


🏁 Script executed:

#!/bin/bash
# Check how scripts/cdn_deploy.js parses/uses the tag argument
fd -a 'cdn_deploy.js' | xargs -I{} rg -n -A2 -B2 --pretty --no-heading '\b(tag|version)\b' {}
# Also look for a regex stripping a leading "v"
rg -n --pretty -e '(^|[^a-zA-Z])v?\d+\.\d+\.\d+' -e 'replace\(.*"^v",' -g 'scripts/**'

Length of output: 1260


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo " locate cdn_deploy.js files..."
files=$(fd -a cdn_deploy.js || true)
if [ -z "$files" ]; then
  echo "cdn_deploy.js not found; will search repo for getVersions and tag-normalizing code"
else
  for f in $files; do
    echo "=== FILE: $f ==="
    echo "---- head (first 240 lines) ----"
    nl -ba -w4 -s': ' "$f" | sed -n '1,240p'
    echo
  done
fi

echo
echo "---- grep repository for getVersions definitions ----"
rg -n --hidden -S "function\\s+getVersions\\b|const\\s+getVersions\\b|getVersions\\s*=\\s*\\(" -g '!**/node_modules/**' -n -C5 || true

echo
echo "---- grep for common leading-'v' stripping / checks ----"
rg -n --hidden -S -g '!**/node_modules/**' -n -C5 \
  "\.replace\(\s*/\^v/|\breplace\(\s*['\"]\^v|\.replace\(\s*['\"]v['\"]|startsWith\(\s*['\"]v['\"]|tag\.replace\(|config\.tag\.replace\(" \
  || true

echo
echo "---- grep for usages of config.tag (to see how it's consumed) ----"
rg -n --hidden -S -g '!**/node_modules/**' -n -C5 "config\.tag|\\btag\\b" || true

Length of output: 160


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Searching for scripts/cdn_deploy.js..."
files=$(fd -a cdn_deploy.js || true)
if [ -z "$files" ]; then
  echo "No cdn_deploy.js found."
else
  for f in $files; do
    echo
    echo "=== FILE: $f ==="
    awk '{printf "%04d: %s\n", NR, $0}' "$f" | sed -n '1,400p'
    echo "---- end $f ----"
  done
fi

echo
echo "---- Searching for getVersions definition(s) across repo ----"
rg -n --hidden -S "function\\s+getVersions\\b|const\\s+getVersions\\b|getVersions\\s*=\\s*\\(" -g '!**/node_modules/**' || true

echo
echo "---- If any getVersions definitions found, show their files (first 300 lines) ----"
rg -n --hidden -S "function\\s+getVersions\\b|const\\s+getVersions\\b|getVersions\\s*=\\s*\\(" -g '!**/node_modules/**' | cut -d: -f1 | sort -u | while read -r gf; do
  echo
  echo "=== getVersions file: $gf ==="
  awk '{printf "%04d: %s\n", NR, $0}' "$gf" | sed -n '1,300p'
  echo "---- end $gf ----"
done

echo
echo "---- Search scripts/ for tag-normalizing patterns (replace /^v/, startsWith('v'), slice(1), substring(1)) ----"
rg -n --hidden -S -g 'scripts/**' "replace\\(.*\\^v|replace\\(.*['\"]\\^v|/\\^v/|startsWith\\(\\s*['\"]v['\"]|slice\\(1\\)|substring\\(1\\)" || true

echo
echo "---- Search for usages of config.tag and tag-related git checks ----"
rg -n --hidden -S -g '!**/node_modules/**' "config\\.tag|\\btag --points-at HEAD\\b|checkout tags/|getVersions\\(|\\btag\\b" -n -C3 || true

Length of output: 5580


Confirm expected tag format for cdn_deploy.js.

cdn_deploy.js uses config.tag verbatim — getVersions(fullVersion) does not strip a leading "v" and will produce versions like "v1", "v1.2", "v1.2.3". Passing ${{ github.ref_name }} (e.g. "v1.2.3") will embed the leading "v" in uploaded filenames.
Either pass the tag without the leading "v" from the workflow or normalize/remove a leading "v" in scripts/cdn_deploy.js before calling getVersions.

Locations: scripts/cdn_deploy.js — getVersions (lines 118–121) and invocation at line 58; .github/workflows/publish-cdn.yml — line 28.

🤖 Prompt for AI Agents
.github/workflows/publish-cdn.yml line 28 and scripts/cdn_deploy.js around
invocation at line 58 and getVersions at lines 118–121: the workflow passes
github.ref_name (e.g. "v1.2.3") which leaves a leading "v" into config.tag and
causes getVersions to generate filenames with a leading "v"; fix by normalizing
the tag to strip a leading "v" either in the workflow or in the script —
easiest: update scripts/cdn_deploy.js to sanitize config.tag at start (e.g., if
it starts with "v" remove that character) before calling getVersions so all
generated version strings and filenames never include the leading "v".

27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release packages

on:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
Comment on lines +14 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Pin checkout to the release tag.

On release events, explicitly checking out the tag avoids any mismatch with default-branch HEAD.

-      - uses: actions/checkout@v3
-        with:
-          submodules: true
+      - uses: actions/checkout@v4
+        with:
+          submodules: true
+          ref: ${{ github.event.release.tag_name }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.event.release.tag_name }}
- uses: actions/setup-node@v3
🧰 Tools
🪛 actionlint (1.7.7)

14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


17-17: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
In .github/workflows/release.yml around lines 14 to 17, the checkout step is not
pinned to the release tag which can cause the workflow to use default-branch
HEAD; update the actions/checkout step to explicitly check out the release tag
by adding a ref field set to the workflow ref (for release events use ref: ${{
github.ref }}), keeping submodules: true so the build uses the exact tag being
released.

with:
node-version: '20.10.0'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies and publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm ci
npm run build
npm publish --provenance --access public
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
4. Run `npm version <VERSION_NUMBER> --no-git-tag-version` with the new version and add the changes to the git index
5. Update the version number to the new version in `src/platform/react-hooks/src/AblyReactHooks.ts`
6. Create a PR for the release branch
7. Once the release PR is landed to the `main` branch, checkout the `main` branch locally (remember to pull the remote changes) and run `npm run build`
8. Run `git tag <VERSION_NUMBER>` with the new version and push the tag to GitHub with `git push <REMOTE> <VERSION_NUMBER>` (usually `git push origin <VERSION_NUMBER>`)
9. Run `npm publish .` (should require OTP) - publishes to NPM
10. Run the GitHub action "Publish to CDN" with the new tag name
11. Visit https://github.com/ably/ably-js/tags and create a GitHub release based on the new tag (for release notes, you generally can just copy the notes you added to the CHANGELOG)
12. Update the [Ably Changelog](https://changelog.ably.com/) (via [headwayapp](https://headwayapp.co/)) with these changes (again, you can just copy the notes you added to the CHANGELOG)
7. Once all tests are passing, land the release branch into `main`.
8. Create a GitHub release with the appropriate tag. For release notes, you generally can just copy the notes you added to the CHANGELOG.
9. Verify that the Release and CDN publish actions have run successfully.
10. Update the [Ably Changelog](https://changelog.ably.com/) (via [headwayapp](https://headwayapp.co/)) with these changes (again, you can just copy the notes you added to the CHANGELOG)

## Building the library

Expand Down
Loading