Skip to content

Commit bf6ce81

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 bf6ce81

File tree

2 files changed

+54
-28
lines changed

2 files changed

+54
-28
lines changed

.github/workflows/publish-dev.yml

Lines changed: 11 additions & 3 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

scripts/publish-dev.sh

Lines changed: 43 additions & 25 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+
# Generate 6-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
@@ -60,13 +53,13 @@ update_package_version() {
6053
const newPatch = parseInt('${CURRENT_VERSION}'.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 minor 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)