Skip to content

Conversation

@Muhammad-Altabba
Copy link
Contributor

PR Description: Automated Dev Package Publishing

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

This PR implements an automated CI/CD pipeline for publishing development
versions of npm packages. The workflow publishes packages automatically when
code is merged into epic-** branches and can also be triggered manually via
GitHub Actions UI.

1. GitHub Actions Workflow (.github/workflows/publish-dev.yml)

  • ✅ Triggers automatically on push to epic-** branches

  • ✅ Supports manual dispatch with optional reason input

    Image
  • ✅ Uses concurrency control to prevent overlapping publishes

  • ✅ Generates detailed release summaries with installation instructions

  • ✅ Builds all packages before publishing

  • ✅ Uses frozen lockfile for reproducible installs

2. Publish Script (scripts/publish-dev.sh)

  • ✅ Generates dev versions following format:
    {next-version}-dev.{branch-name}.{date}.{commit-hash}.{build-number}

  • ✅ Handles first-time dev publishes by bumping patch version

  • ✅ Subsequent publishes from same branch reuse base version

  • ✅ Publishes to npm with dev tag for easy installation

  • ✅ Restores original package.json versions after publish (no git changes by a chance if someone executed the publishing locally)

  • ✅ Tracks and reports all published packages with a summary which will be
    like:

    https://github.com/Muhammad-Altabba/taco-web/actions/runs/18629604101/attempts/1#summary-53112397136

  • ✅ Sanitizes branch names for npm version compatibility

    For example change epic-123/test/branchepic-123-test-branch

3. Package.json Update

  • ✅ Added publish:dev script: ./scripts/publish-dev.sh

4. README.md Documentation

  • ✅ Added "Development Versions" section with:
    • Installation instructions for dev packages
    • Version format explanation
    • Clear guidance on when to use/not use dev versions
    • Examples

Issues fixed/closed:

Why it's needed:

This feature addresses a critical development workflow gap. Currently,
developers testing new features from epic-** branches must either:

  • ❌ Manually publish packages (time-consuming and error-prone)
  • ❌ Use local linking with npm link or pnpm link (complex setup, path
    issues)
  • ❌ Wait for the next official release (delays feedback cycles, blocks testing)

Benefits with automated dev package publishing:

Immediate Testing: Install pre-release versions directly from npm using
@dev tag that is usable in other projects without local linking.

CI/CD Integration: Automated publishing ensures consistency, speed and
reduces human error.

Manual Control: Maintainers can trigger publishes on-demand when needed.

Notes:

  • To see the manual publishing option, the changes needs to be merged to the default branch. However, for testing the target branch could be set as default, merge to it, then set back the old default branch.

  • It is easy to change this PR so the publish happens only automatically or manually, if wanted.

@Muhammad-Altabba
Copy link
Contributor Author

At the last commit:

  1. Branch Pattern Restriction
  • Updated workflow to only trigger automatically on epic branches following the
    pattern: epic-v[0-9]+.[0-9]+.x
  • Examples: epic-v1.0.x, epic-v2.3.x
  • Auto-trigger temporarily disabled (commented out)
  1. Package Exclusion

    Added exclusion logic for pre and test-utils packages.

  2. Manual Version Suffix Support

  • Added a required version_suffix input for manual workflow triggers
  • Manual mode: Creates versions like x.y.z-dev.{suffix}.{8-char-hash} with
    tag dev-{suffix}
    • Example: 0.5.1-dev.access-client.a1b2c3d4 → tag: dev-access-client
  • Auto mode: Creates versions like x.y.z-dev.{8-char-hash} with tag dev
    • Example: 0.5.1-dev.a1b2c3d4 → tag: dev

Version Format Examples

Mode Version Example Tag Example Use Case
Manual 0.5.1-dev.access-client.a1b2c3d4 dev-access-client Specific test versions
Auto 0.5.1-dev.a1b2c3d4 dev Latest dev from commit

This comment was marked as outdated.

- Support custom version suffixes for manual workflow triggers
- Exclude 'pre' and 'test-utils' from dev publishing
- Simplify auto-publish versions to use only git hash
- Restrict auto-trigger to epic-v*.*.x branches and comment the logic for now
@Muhammad-Altabba Muhammad-Altabba force-pushed the ci/publish-dev-versions-manually-or-on-epic-merge branch from bf6ce81 to fe3f015 Compare October 20, 2025 17:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- ❌ Production environments
- ❌ Stable development work

**Note:** Dev versions are automatically published when code is merged to `epic-v*.*.x` branches and can be manually published with custom tags. These versions are unstable and may contain breaking changes or even sometimes broken code..
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

Double period at the end of the sentence should be a single period.

Suggested change
**Note:** Dev versions are automatically published when code is merged to `epic-v*.*.x` branches and can be manually published with custom tags. These versions are unstable and may contain breaking changes or even sometimes broken code..
**Note:** Dev versions are automatically published when code is merged to `epic-v*.*.x` branches and can be manually published with custom tags. These versions are unstable and may contain breaking changes or even sometimes broken code.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,98 @@
name: Publish Dev Packages

on:
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The commented-out push trigger should either be removed or accompanied by a comment explaining why it's disabled, especially since the PR description mentions auto-publishing on push to epic-** branches.

Suggested change
on:
on:
# The push trigger is currently disabled.
# Reason: Auto-publishing on push to epic-v* branches is temporarily suspended pending workflow review and improvements.
# See PR description for details. Uncomment to re-enable automatic publishing on push.

Copilot uses AI. Check for mistakes.
CURRENT_VERSION=$(node -p "require('./${package_json}').version")

# Check if this is the first dev publish (version doesn't have -dev suffix)
if [[ ! "$CURRENT_VERSION" =~ -dev\. ]]; then
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The regex pattern -dev\. will not match versions like 1.2.3-dev without a dot after 'dev'. This could cause incorrect version bumping if a package has a -dev suffix without the dot separator. Consider using -dev instead of -dev\. to match both cases.

Suggested change
if [[ ! "$CURRENT_VERSION" =~ -dev\. ]]; then
if [[ ! "$CURRENT_VERSION" =~ -dev(\.|$) ]]; then

Copilot uses AI. Check for mistakes.
echo -e "${BLUE}dev publish - bumping patch version${NC}"
else
# Subsequent dev publish: strip existing -dev.* suffix to prevent duplication
BASE_VERSION="${CURRENT_VERSION%%-dev.*}"
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

This string manipulation is inconsistent with the regex check on line 46. If line 46 is changed to match -dev without requiring a dot, this line should use ${CURRENT_VERSION%%-dev*} to handle both -dev and -dev. prefixes consistently.

Suggested change
BASE_VERSION="${CURRENT_VERSION%%-dev.*}"
BASE_VERSION="${CURRENT_VERSION%%-dev*}"

Copilot uses AI. Check for mistakes.
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

LGTM! I left some comments tho


## Tutorial

To learn more, follow the tutorial at Threshold
Copy link
Member

Choose a reason for hiding this comment

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

Not related with this PR, but we could also change this line and substitute Threshold Network's docs by TACo's docs.

name: Publish Dev Packages

on:
#push:
Copy link
Member

Choose a reason for hiding this comment

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

Just curious. Why are we preventing to have this run on push? Maybe I miss some chat about it.

- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, but this should be enough, shouldn't it?

Suggested change
fetch-depth: 0
fetch-depth: 1

return 0 # true, is excluded
fi
done
return 1 # false, not excluded
Copy link
Member

Choose a reason for hiding this comment

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

in bash 1 is false and 0 is true 🤯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants