Skip to content

Commit fe3f015

Browse files
feat(ci): add manual version suffix and package exclusion to dev publish
- 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
1 parent da03a07 commit fe3f015

File tree

3 files changed

+84
-40
lines changed

3 files changed

+84
-40
lines changed

.github/workflows/publish-dev.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
name: Publish Dev Packages
22

33
on:
4-
push:
5-
branches:
6-
- 'epic-**'
4+
#push:
5+
# branches:
6+
# - 'epic-v[0-9]+.[0-9]+.x'
77
workflow_dispatch:
88
inputs:
9+
version_suffix:
10+
description:
11+
'Version and tag suffix (used in tag: dev-{suffix} and version:
12+
x.y.z-dev.{suffix}.commit)'
13+
required: true
14+
type: string
915
reason:
1016
description: 'Reason for manual publish'
1117
required: false
@@ -46,6 +52,7 @@ jobs:
4652
id: publish
4753
env:
4854
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
VERSION_SUFFIX: ${{ github.event.inputs.version_suffix }}
4956
run: pnpm run publish:dev
5057

5158
- name: Create release summary
@@ -57,6 +64,7 @@ jobs:
5764
echo "**Build:** \`${GITHUB_RUN_NUMBER}\`" >> $GITHUB_STEP_SUMMARY
5865
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
5966
echo "**Trigger:** Manual (by ${{ github.actor }})" >> $GITHUB_STEP_SUMMARY
67+
echo "**Version Suffix:** ${{ github.event.inputs.version_suffix }}" >> $GITHUB_STEP_SUMMARY
6068
echo "**Reason:** ${{ github.event.inputs.reason }}" >> $GITHUB_STEP_SUMMARY
6169
fi
6270
echo "" >> $GITHUB_STEP_SUMMARY
@@ -77,7 +85,14 @@ jobs:
7785
echo "### Installation" >> $GITHUB_STEP_SUMMARY
7886
echo "" >> $GITHUB_STEP_SUMMARY
7987
echo '```bash' >> $GITHUB_STEP_SUMMARY
80-
echo 'pnpm add @nucypher/shared@dev' >> $GITHUB_STEP_SUMMARY
81-
echo 'pnpm add @nucypher/taco@dev' >> $GITHUB_STEP_SUMMARY
82-
echo 'pnpm add @nucypher/taco-auth@dev' >> $GITHUB_STEP_SUMMARY
88+
if [ -n "${{ github.event.inputs.version_suffix }}" ]; then
89+
TAG="dev-${{ github.event.inputs.version_suffix }}"
90+
echo "pnpm add @nucypher/shared@${TAG}" >> $GITHUB_STEP_SUMMARY
91+
echo "pnpm add @nucypher/taco@${TAG}" >> $GITHUB_STEP_SUMMARY
92+
echo "pnpm add @nucypher/taco-auth@${TAG}" >> $GITHUB_STEP_SUMMARY
93+
else
94+
echo 'pnpm add @nucypher/shared@dev' >> $GITHUB_STEP_SUMMARY
95+
echo 'pnpm add @nucypher/taco@dev' >> $GITHUB_STEP_SUMMARY
96+
echo 'pnpm add @nucypher/taco-auth@dev' >> $GITHUB_STEP_SUMMARY
97+
fi
8398
echo '```' >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,44 @@ pnpm add @nucypher/taco
1818

1919
### Development Versions
2020

21-
For testing features from `epic-**` branches before they're officially released, you can install development versions published with the `dev` tag:
21+
Development versions are available for testing features before official releases. They can be installed using npm tags:
2222

2323
```bash
24+
# Latest auto-published dev version
2425
pnpm add @nucypher/taco@dev
2526
pnpm add @nucypher/taco-auth@dev
2627
pnpm add @nucypher/shared@dev
28+
29+
# Specific manually-published version with custom tag
30+
pnpm add @nucypher/taco@dev-access-client
31+
pnpm add @nucypher/taco-auth@dev-access-client
32+
pnpm add @nucypher/shared@dev-access-client
2733
```
2834

29-
**Development version format:**
35+
**Development version formats:**
36+
37+
*Auto-published (from epic versions branches):*
3038
```
31-
{next-version}-dev.{branch-name}.{date}.{commit-hash}.{build-number}
39+
{version}-dev.{commit-hash}
40+
Example: 0.5.1-dev.a1b2c3d4
3241
```
3342

34-
**Example:**
43+
*Manually published (custom suffix):*
3544
```
36-
1.2.4-dev.epic-new-feature.20250120.aeed464a.17
45+
{version}-dev.{suffix}.{commit-hash}
46+
Example: 0.5.1-dev.access-client.a1b2c3d4
3747
```
3848

3949
**When to use dev versions:**
40-
- ✅ Testing new features from epic branches which contains pre-release functionality
50+
- ✅ Testing new features
4151
- ✅ Providing feedback on unreleased features
52+
- ✅ Testing specific feature branches via custom tags (e.g., `@dev-access-client`)
4253

4354
**When NOT to use dev versions:**
4455
- ❌ Production environments
4556
- ❌ Stable development work
4657

47-
**Note:** Dev versions are automatically published when code is merged to `epic-**` branches and sometimes manually published. These versions are unstable and may contain breaking changes or even sometimes broken code.
58+
**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..
4859

4960
## Tutorial
5061

scripts/publish-dev.sh

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,22 @@ NC='\033[0m' # No Color
1111

1212
echo -e "${BLUE}📦 Publishing development packages...${NC}"
1313

14-
# Extract branch name
15-
if [ -n "$GITHUB_REF" ]; then
16-
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
14+
SHORT_HASH=$(git rev-parse --short=8 HEAD)
15+
16+
# Check if VERSION_SUFFIX is provided (manual workflow)
17+
if [ -n "$VERSION_SUFFIX" ]; then
18+
echo -e "${BLUE}Using manual version suffix:${NC} $VERSION_SUFFIX"
19+
DEV_TAG="dev-${VERSION_SUFFIX}"
20+
# Append 8-character hash from git commit
21+
VERSION_ID="${VERSION_SUFFIX}.${SHORT_HASH}"
1722
else
18-
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
23+
# Auto mode: use only short hash
24+
DEV_TAG="dev"
25+
VERSION_ID="${SHORT_HASH}"
1926
fi
2027

21-
# Sanitize branch name for npm version (replace / with -)
22-
SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\//-/g')
23-
24-
# Get timestamp
25-
TIMESTAMP=$(date +%Y%m%d)
26-
27-
# Build number from GitHub or git commit
28-
if [ -n "$GITHUB_RUN_NUMBER" ]; then
29-
BUILD_NUMBER="$(git rev-parse --short HEAD).$GITHUB_RUN_NUMBER"
30-
else
31-
BUILD_NUMBER=$(git rev-parse --short HEAD)
32-
fi
33-
34-
echo -e "${BLUE}Branch:${NC} $SAFE_BRANCH_NAME"
35-
echo -e "${BLUE}Timestamp:${NC} $TIMESTAMP"
36-
echo -e "${BLUE}Build:${NC} $BUILD_NUMBER"
28+
echo -e "${BLUE}Tag:${NC} $DEV_TAG"
29+
echo -e "${BLUE}Version ID:${NC} $VERSION_ID"
3730
echo ""
3831

3932
# Array to track published packages
@@ -51,22 +44,22 @@ update_package_version() {
5144

5245
# Check if this is the first dev publish (version doesn't have -dev suffix)
5346
if [[ ! "$CURRENT_VERSION" =~ -dev\. ]]; then
54-
# First dev publish: bump minor version
47+
# Dev publish: bump patch version
5548
BASE_VERSION=$(node -p "
5649
const ver = '${CURRENT_VERSION}'.split('.');
5750
const major = ver[0];
5851
const minor = ver[1];
5952
const patch = ver[2];
60-
const newPatch = parseInt('${CURRENT_VERSION}'.split('-')[0]) + 1;
53+
const newPatch = parseInt(patch.split('-')[0]) + 1;
6154
\`\${major}.\${minor}.\${newPatch}\`;
6255
")
63-
echo -e "${BLUE}First dev publish - bumping minor version${NC}"
56+
echo -e "${BLUE}dev publish - bumping patch version${NC}"
6457
else
6558
# Subsequent dev publish: strip existing -dev.* suffix to prevent duplication
6659
BASE_VERSION="${CURRENT_VERSION%%-dev.*}"
6760
fi
6861

69-
DEV_VERSION="${BASE_VERSION}-dev.${SAFE_BRANCH_NAME}.${TIMESTAMP}.${BUILD_NUMBER}"
62+
DEV_VERSION="${BASE_VERSION}-dev.${VERSION_ID}"
7063

7164
echo -e "${GREEN}Updating ${PACKAGE_NAME}:${NC} ${CURRENT_VERSION}${DEV_VERSION}"
7265

@@ -80,17 +73,42 @@ update_package_version() {
8073
fi
8174
}
8275

76+
# Packages to exclude from publishing
77+
EXCLUDED_PACKAGES=("pre" "test-utils")
78+
79+
# Function to check if package should be excluded
80+
is_excluded() {
81+
local package_name="$1"
82+
for excluded in "${EXCLUDED_PACKAGES[@]}"; do
83+
if [ "$package_name" = "$excluded" ]; then
84+
return 0 # true, is excluded
85+
fi
86+
done
87+
return 1 # false, not excluded
88+
}
89+
8390
# Update all publishable packages
8491
echo -e "${BLUE}Updating package versions...${NC}"
8592
for package_dir in packages/*/; do
93+
package_name=$(basename "$package_dir")
94+
if is_excluded "$package_name"; then
95+
echo -e "${BLUE}Skipping excluded package:${NC} $package_name"
96+
continue
97+
fi
8698
update_package_version "$package_dir"
8799
done
88100

89101
echo ""
90-
echo -e "${BLUE}Publishing packages with 'dev' tag...${NC}"
102+
echo -e "${BLUE}Publishing packages with '${DEV_TAG}' tag...${NC}"
103+
104+
# Build filter to exclude specific packages
105+
FILTER_ARGS=""
106+
for excluded in "${EXCLUDED_PACKAGES[@]}"; do
107+
FILTER_ARGS="$FILTER_ARGS --filter '!@nucypher/${excluded}'"
108+
done
91109

92-
# Publish all packages with dev tag
93-
pnpm -r --filter './packages/**' publish --tag dev --access public --no-git-checks
110+
# Publish all packages except excluded ones with the appropriate dev tag
111+
eval "pnpm -r --filter './packages/**' $FILTER_ARGS publish --tag ${DEV_TAG} --access public --no-git-checks"
94112

95113
echo ""
96114
echo -e "${BLUE}Restoring original package.json versions...${NC}"

0 commit comments

Comments
 (0)