-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add GitHub workflow and scripts for publishing dev packages to npm #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: epic-v0.7.x
Are you sure you want to change the base?
Changes from all commits
670c09b
da03a07
fe3f015
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,98 @@ | ||||||
| name: Publish Dev Packages | ||||||
|
|
||||||
| on: | ||||||
| #push: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
| # branches: | ||||||
| # - 'epic-v[0-9]+.[0-9]+.x' | ||||||
|
Muhammad-Altabba marked this conversation as resolved.
|
||||||
| workflow_dispatch: | ||||||
| inputs: | ||||||
| version_suffix: | ||||||
| description: | ||||||
| 'Version and tag suffix (used in tag: dev-{suffix} and version: | ||||||
| x.y.z-dev.{suffix}.commit)' | ||||||
| required: true | ||||||
| type: string | ||||||
| reason: | ||||||
| description: 'Reason for manual publish' | ||||||
| required: false | ||||||
| default: 'Manual trigger by maintainer' | ||||||
|
|
||||||
| concurrency: ${{ github.workflow }}-${{ github.ref }} | ||||||
|
|
||||||
| jobs: | ||||||
| publish-dev: | ||||||
| name: Publish development versions to npm | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout repository | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| fetch-depth: 0 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick, but this should be enough, shouldn't it?
Suggested change
|
||||||
|
|
||||||
| - name: Setup pnpm | ||||||
| uses: pnpm/action-setup@v4 | ||||||
| with: | ||||||
| version: 9 | ||||||
|
|
||||||
| - name: Setup Node.js | ||||||
| uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| node-version: '22.x' | ||||||
| cache: 'pnpm' | ||||||
| registry-url: 'https://registry.npmjs.org' | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: pnpm install --frozen-lockfile | ||||||
|
|
||||||
| - name: Build packages | ||||||
| run: pnpm build | ||||||
|
|
||||||
| - name: Publish dev packages | ||||||
| id: publish | ||||||
| env: | ||||||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||
| VERSION_SUFFIX: ${{ github.event.inputs.version_suffix }} | ||||||
| run: pnpm run publish:dev | ||||||
|
|
||||||
| - name: Create release summary | ||||||
| if: success() | ||||||
| run: | | ||||||
| echo "## 🚀 Dev Packages Published" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "**Branch:** \`${GITHUB_REF#refs/heads/}\`" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "**Build:** \`${GITHUB_RUN_NUMBER}\`" >> $GITHUB_STEP_SUMMARY | ||||||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||||||
| echo "**Trigger:** Manual (by ${{ github.actor }})" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "**Version Suffix:** ${{ github.event.inputs.version_suffix }}" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "**Reason:** ${{ github.event.inputs.reason }}" >> $GITHUB_STEP_SUMMARY | ||||||
| fi | ||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "### 📦 Published Packages" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||
| if [ -n "${{ steps.publish.outputs.published_packages }}" ]; then | ||||||
| echo "${{ steps.publish.outputs.published_packages }}" | while IFS= read -r pkg; do | ||||||
| if [ -n "$pkg" ]; then | ||||||
| echo "- \`$pkg\`" >> $GITHUB_STEP_SUMMARY | ||||||
| fi | ||||||
| done | ||||||
| else | ||||||
| echo "- \`@nucypher/shared@dev\`" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "- \`@nucypher/taco@dev\`" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "- \`@nucypher/taco-auth@dev\`" >> $GITHUB_STEP_SUMMARY | ||||||
| fi | ||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "### Installation" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||
| echo '```bash' >> $GITHUB_STEP_SUMMARY | ||||||
| if [ -n "${{ github.event.inputs.version_suffix }}" ]; then | ||||||
| TAG="dev-${{ github.event.inputs.version_suffix }}" | ||||||
| echo "pnpm add @nucypher/shared@${TAG}" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "pnpm add @nucypher/taco@${TAG}" >> $GITHUB_STEP_SUMMARY | ||||||
| echo "pnpm add @nucypher/taco-auth@${TAG}" >> $GITHUB_STEP_SUMMARY | ||||||
| else | ||||||
| echo 'pnpm add @nucypher/shared@dev' >> $GITHUB_STEP_SUMMARY | ||||||
| echo 'pnpm add @nucypher/taco@dev' >> $GITHUB_STEP_SUMMARY | ||||||
| echo 'pnpm add @nucypher/taco-auth@dev' >> $GITHUB_STEP_SUMMARY | ||||||
| fi | ||||||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,47 @@ Full documentation can be found [here](https://docs.taco.build/). | |||||
| pnpm add @nucypher/taco | ||||||
| ``` | ||||||
|
|
||||||
| ### Development Versions | ||||||
|
|
||||||
| Development versions are available for testing features before official releases. They can be installed using npm tags: | ||||||
|
|
||||||
| ```bash | ||||||
| # Latest auto-published dev version | ||||||
| pnpm add @nucypher/taco@dev | ||||||
| pnpm add @nucypher/taco-auth@dev | ||||||
| pnpm add @nucypher/shared@dev | ||||||
|
|
||||||
| # Specific manually-published version with custom tag | ||||||
| pnpm add @nucypher/taco@dev-access-client | ||||||
| pnpm add @nucypher/taco-auth@dev-access-client | ||||||
| pnpm add @nucypher/shared@dev-access-client | ||||||
| ``` | ||||||
|
|
||||||
| **Development version formats:** | ||||||
|
|
||||||
| *Auto-published (from epic versions branches):* | ||||||
| ``` | ||||||
| {version}-dev.{commit-hash} | ||||||
| Example: 0.5.1-dev.a1b2c3d4 | ||||||
| ``` | ||||||
|
|
||||||
| *Manually published (custom suffix):* | ||||||
| ``` | ||||||
| {version}-dev.{suffix}.{commit-hash} | ||||||
| Example: 0.5.1-dev.access-client.a1b2c3d4 | ||||||
| ``` | ||||||
|
|
||||||
| **When to use dev versions:** | ||||||
| - ✅ Testing new features | ||||||
| - ✅ Providing feedback on unreleased features | ||||||
| - ✅ Testing specific feature branches via custom tags (e.g., `@dev-access-client`) | ||||||
|
|
||||||
| **When NOT to use dev versions:** | ||||||
| - ❌ 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.. | ||||||
|
||||||
| **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. |
There was a problem hiding this comment.
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.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,140 @@ | ||||||
| #!/bin/bash | ||||||
| set -e | ||||||
|
|
||||||
| # Script to publish development versions of packages | ||||||
| # Usage: ./scripts/publish-dev.sh | ||||||
|
|
||||||
| # Colors for output | ||||||
| GREEN='\033[0;32m' | ||||||
| BLUE='\033[0;34m' | ||||||
| NC='\033[0m' # No Color | ||||||
|
|
||||||
| echo -e "${BLUE}📦 Publishing development packages...${NC}" | ||||||
|
|
||||||
| SHORT_HASH=$(git rev-parse --short=8 HEAD) | ||||||
|
|
||||||
| # Check if VERSION_SUFFIX is provided (manual workflow) | ||||||
| if [ -n "$VERSION_SUFFIX" ]; then | ||||||
| echo -e "${BLUE}Using manual version suffix:${NC} $VERSION_SUFFIX" | ||||||
| DEV_TAG="dev-${VERSION_SUFFIX}" | ||||||
| # Append 8-character hash from git commit | ||||||
| VERSION_ID="${VERSION_SUFFIX}.${SHORT_HASH}" | ||||||
| else | ||||||
| # Auto mode: use only short hash | ||||||
| DEV_TAG="dev" | ||||||
| VERSION_ID="${SHORT_HASH}" | ||||||
| fi | ||||||
|
|
||||||
| echo -e "${BLUE}Tag:${NC} $DEV_TAG" | ||||||
| echo -e "${BLUE}Version ID:${NC} $VERSION_ID" | ||||||
| echo "" | ||||||
|
|
||||||
| # Array to track published packages | ||||||
| declare -a PUBLISHED_PACKAGES=() | ||||||
|
|
||||||
| # Function to update package version | ||||||
| update_package_version() { | ||||||
| local package_dir="${1%/}" # Remove trailing slash | ||||||
| local package_json="${package_dir}/package.json" | ||||||
|
|
||||||
| if [ -f "$package_json" ]; then | ||||||
| # Use ./ prefix for relative paths in require() | ||||||
| PACKAGE_NAME=$(node -p "require('./${package_json}').name") | ||||||
| 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 | ||||||
|
||||||
| if [[ ! "$CURRENT_VERSION" =~ -dev\. ]]; then | |
| if [[ ! "$CURRENT_VERSION" =~ -dev(\.|$) ]]; then |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
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.
| BASE_VERSION="${CURRENT_VERSION%%-dev.*}" | |
| BASE_VERSION="${CURRENT_VERSION%%-dev*}" |
There was a problem hiding this comment.
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 🤯
There was a problem hiding this comment.
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.