Skip to content

Commit 8fea18e

Browse files
committed
updated to add support for nodejs
1 parent 858baf8 commit 8fea18e

File tree

2 files changed

+213
-1
lines changed

2 files changed

+213
-1
lines changed

.github/workflows/release.yml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,85 @@ jobs:
8282
TWINE_USERNAME: __token__
8383
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
8484
run: |
85-
twine upload dist/*
85+
twine upload dist/*
86+
87+
publish-npm:
88+
needs: build
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v3
92+
93+
- name: Set up Node.js
94+
uses: actions/setup-node@v3
95+
with:
96+
node-version: '18'
97+
registry-url: 'https://registry.npmjs.org'
98+
99+
- name: Install GitHub CLI
100+
run: |
101+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
102+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
103+
sudo apt update
104+
sudo apt install gh
105+
106+
- name: Extract version from tag
107+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
108+
109+
- name: Create JS package binaries directory
110+
run: mkdir -p pathik-js/bin
111+
112+
- name: Download released binaries
113+
run: |
114+
# Create a temporary directory to download the binaries
115+
mkdir -p temp_binaries
116+
117+
# Download binaries from the GitHub release
118+
gh release download v${{ env.VERSION }} --dir temp_binaries
119+
120+
# List downloaded files
121+
ls -la temp_binaries
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
125+
- name: Copy binaries to JS package
126+
run: |
127+
# Create platform-specific directories
128+
mkdir -p pathik-js/bin/darwin-amd64
129+
mkdir -p pathik-js/bin/darwin-arm64
130+
mkdir -p pathik-js/bin/linux-amd64
131+
mkdir -p pathik-js/bin/linux-arm64
132+
mkdir -p pathik-js/bin/win32-amd64
133+
134+
# Copy binaries to the correct locations
135+
cp temp_binaries/pathik_bin_darwin_amd64 pathik-js/bin/darwin-amd64/pathik_bin
136+
cp temp_binaries/pathik_bin_darwin_arm64 pathik-js/bin/darwin-arm64/pathik_bin
137+
cp temp_binaries/pathik_bin_linux_amd64 pathik-js/bin/linux-amd64/pathik_bin
138+
cp temp_binaries/pathik_bin_linux_arm64 pathik-js/bin/linux-arm64/pathik_bin
139+
cp temp_binaries/pathik_bin_windows_amd64.exe pathik-js/bin/win32-amd64/pathik_bin.exe
140+
141+
# Make binaries executable
142+
chmod +x pathik-js/bin/darwin-amd64/pathik_bin
143+
chmod +x pathik-js/bin/darwin-arm64/pathik_bin
144+
chmod +x pathik-js/bin/linux-amd64/pathik_bin
145+
chmod +x pathik-js/bin/linux-arm64/pathik_bin
146+
147+
# Verify the structure
148+
find pathik-js/bin -type f | sort
149+
150+
- name: Update package version
151+
run: |
152+
cd pathik-js
153+
npm version ${{ env.VERSION }} --no-git-tag-version
154+
cat package.json | grep version
155+
156+
- name: Install dependencies
157+
run: |
158+
cd pathik-js
159+
npm ci
160+
161+
- name: Publish to npm
162+
run: |
163+
cd pathik-js
164+
npm publish
165+
env:
166+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

new-version.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
3+
# Colors for output
4+
GREEN='\033[0;32m'
5+
YELLOW='\033[1;33m'
6+
RED='\033[0;31m'
7+
NC='\033[0m' # No Color
8+
9+
# Function to print messages with color
10+
print_message() {
11+
echo -e "${GREEN}$1${NC}"
12+
}
13+
14+
print_warning() {
15+
echo -e "${YELLOW}$1${NC}"
16+
}
17+
18+
print_error() {
19+
echo -e "${RED}$1${NC}"
20+
}
21+
22+
# Get the latest tag
23+
get_latest_tag() {
24+
git fetch --tags
25+
latest_tag=$(git tag -l "v*" --sort=-v:refname | head -n 1)
26+
27+
if [ -z "$latest_tag" ]; then
28+
print_warning "No existing version tags found. Starting with v0.1.0."
29+
latest_tag="v0.1.0"
30+
else
31+
print_message "Latest version tag: $latest_tag"
32+
fi
33+
34+
# Strip the 'v' prefix for version calculations
35+
latest_version=${latest_tag#v}
36+
}
37+
38+
# Increment version
39+
increment_version() {
40+
# Split version into parts
41+
IFS='.' read -r -a version_parts <<< "$latest_version"
42+
43+
major=${version_parts[0]}
44+
minor=${version_parts[1]}
45+
patch=${version_parts[2]}
46+
47+
case $1 in
48+
major)
49+
major=$((major + 1))
50+
minor=0
51+
patch=0
52+
;;
53+
minor)
54+
minor=$((minor + 1))
55+
patch=0
56+
;;
57+
patch|*)
58+
patch=$((patch + 1))
59+
;;
60+
esac
61+
62+
new_version="$major.$minor.$patch"
63+
new_tag="v$new_version"
64+
}
65+
66+
# Main script
67+
68+
# Check if we're in a git repository
69+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
70+
print_error "Not in a git repository!"
71+
exit 1
72+
fi
73+
74+
# Get the latest tag
75+
get_latest_tag
76+
77+
# Process command line arguments
78+
if [ $# -eq 0 ]; then
79+
# No arguments - show interactive menu
80+
echo "Current version: $latest_tag"
81+
echo "What would you like to do?"
82+
echo "1) Increment patch version (default)"
83+
echo "2) Increment minor version"
84+
echo "3) Increment major version"
85+
echo "4) Specify exact version"
86+
87+
read -p "Select option [1-4] (default: 1): " option
88+
89+
case $option in
90+
2) increment_version minor ;;
91+
3) increment_version major ;;
92+
4)
93+
read -p "Enter version (without 'v' prefix): " user_version
94+
new_version=$user_version
95+
new_tag="v$new_version"
96+
;;
97+
*) increment_version patch ;;
98+
esac
99+
else
100+
# Version provided as command line argument
101+
if [[ $1 == v* ]]; then
102+
new_tag=$1
103+
new_version=${new_tag#v}
104+
else
105+
new_version=$1
106+
new_tag="v$new_version"
107+
fi
108+
fi
109+
110+
print_message "Creating new version tag: $new_tag"
111+
112+
# Check if there are uncomitted changes
113+
if [ -n "$(git status --porcelain)" ]; then
114+
print_warning "You have uncommitted changes. It's recommended to commit them before creating a new release."
115+
read -p "Continue anyway? (y/n): " continue_choice
116+
if [[ $continue_choice != "y" && $continue_choice != "Y" ]]; then
117+
print_message "Aborting. Please commit your changes first."
118+
exit 0
119+
fi
120+
fi
121+
122+
# Create and push the tag
123+
print_message "Creating tag $new_tag with message 'Release $new_tag'..."
124+
git tag -a "$new_tag" -m "Release $new_tag"
125+
126+
print_message "Pushing tag to remote..."
127+
git push origin "$new_tag"
128+
129+
print_message "Version $new_tag has been created and pushed!"
130+
print_message "GitHub Actions workflow should start automatically."
131+
print_message "Check the progress at: https://github.com/$(git remote get-url origin | sed 's/.*github.com[:/]\(.*\).git/\1/')/actions"

0 commit comments

Comments
 (0)