-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·132 lines (104 loc) · 4.87 KB
/
release.sh
File metadata and controls
executable file
·132 lines (104 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}=== declutter Release Script ===${NC}\n"
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo -e "${RED}Error: GitHub CLI (gh) is not installed${NC}"
echo "Install it from: https://cli.github.com"
exit 1
fi
# Check if bun is installed
if ! command -v bun &> /dev/null; then
echo -e "${RED}Error: Bun is not installed${NC}"
echo "Install it from: https://bun.sh"
exit 1
fi
# Prompt for version
echo -e "${YELLOW}Enter the version for this release (e.g., 1.0.0, 0.1.0, or 'latest'):${NC}"
read -p "> " VERSION
# Validate version format (basic semantic versioning or "latest")
if [[ "$VERSION" != "latest" ]] && ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo -e "${RED}Error: Invalid version format. Please use semantic versioning (e.g., 1.0.0) or 'latest'${NC}"
exit 1
fi
# Check if release tag already exists (skip for "latest" as it may be updated)
if [[ "$VERSION" != "latest" ]]; then
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo -e "${RED}Error: Release tag v$VERSION already exists${NC}"
exit 1
fi
fi
echo -e "\n${YELLOW}Building project for all platforms...${NC}\n"
# Build the project
bun run build
if [ ! -d "dist" ]; then
echo -e "${RED}Error: Build failed - dist directory not found${NC}"
exit 1
fi
echo -e "\n${GREEN}✓ Build completed successfully${NC}\n"
# List built binaries
echo -e "${YELLOW}Built binaries:${NC}"
ls -lh dist/ | grep -E '^-' | awk '{print " - " $9 " (" $5 ")"}'
# Code sign macOS binaries
if [[ "$OSTYPE" == "darwin"* ]]; then
echo -e "\n${YELLOW}Code signing macOS binaries...${NC}\n"
# Check if codesign is available
if ! command -v codesign &> /dev/null; then
echo -e "${RED}Warning: codesign command not found. Skipping code signing.${NC}"
else
# List available signing identities
IDENTITIES=$(security find-identity -v -p codesigning 2>/dev/null | grep -oP '^\s*\K[^\s]+(?=\s)' | head -n 1)
if [ -z "$IDENTITIES" ]; then
echo -e "${YELLOW}No code signing certificates found. Using ad-hoc signing...${NC}"
# Ad-hoc signing (works locally, not for distribution)
codesign -s - --force --preserve-metadata=entitlements,requirements,flags,runtime dist/declutter-macos-x64
codesign -s - --force --preserve-metadata=entitlements,requirements,flags,runtime dist/declutter-macos-arm64
else
echo -e "${YELLOW}Found code signing identity. Signing binaries...${NC}"
codesign -s "$IDENTITIES" --force --preserve-metadata=entitlements,requirements,flags,runtime dist/declutter-macos-x64
codesign -s "$IDENTITIES" --force --preserve-metadata=entitlements,requirements,flags,runtime dist/declutter-macos-arm64
fi
# Verify signatures
echo -e "\n${YELLOW}Verifying code signatures...${NC}"
codesign -v dist/declutter-macos-x64 && echo -e "${GREEN}✓ Signed: declutter-macos-x64${NC}" || echo -e "${RED}✗ Failed: declutter-macos-x64${NC}"
codesign -v dist/declutter-macos-arm64 && echo -e "${GREEN}✓ Signed: declutter-macos-arm64${NC}" || echo -e "${RED}✗ Failed: declutter-macos-arm64${NC}"
fi
else
echo -e "${YELLOW}Not running on macOS. Skipping code signing.${NC}"
fi
# Create tar.gz archives for all binaries
echo -e "\n${YELLOW}Creating tar.gz archives...${NC}\n"
cd dist
# Create archive for Windows
COPYFILE_DISABLE=1 tar -czf declutter-windows-x64.tar.gz declutter-windows-x64.exe
echo -e "${GREEN}✓ Created declutter-windows-x64.tar.gz${NC}"
# Create archive for macOS x64
tar -czf declutter-macos-x64.tar.gz declutter-macos-x64
echo -e "${GREEN}✓ Created declutter-macos-x64.tar.gz${NC}"
# Create archive for macOS ARM64
tar -czf declutter-macos-arm64.tar.gz declutter-macos-arm64
echo -e "${GREEN}✓ Created declutter-macos-arm64.tar.gz${NC}"
# Create archive for Linux x64
COPYFILE_DISABLE=1 tar -czf declutter-linux-x64.tar.gz declutter-linux-x64
echo -e "${GREEN}✓ Created declutter-linux-x64.tar.gz${NC}"
# Create archive for Linux ARM64
COPYFILE_DISABLE=1 tar -czf declutter-linux-arm64.tar.gz declutter-linux-arm64
echo -e "${GREEN}✓ Created declutter-linux-arm64.tar.gz${NC}"
cd ..
# Create the release
echo -e "\n${YELLOW}Creating GitHub release v$VERSION...${NC}\n"
gh release create "v$VERSION" \
--title "declutter v$VERSION" \
--notes "Release v$VERSION of declutter" \
dist/declutter-windows-x64.tar.gz \
dist/declutter-macos-x64.tar.gz \
dist/declutter-macos-arm64.tar.gz \
dist/declutter-linux-x64.tar.gz \
dist/declutter-linux-arm64.tar.gz
echo -e "\n${GREEN}✓ Release created successfully!${NC}"
echo -e "${GREEN}✓ Release page: https://github.com/$(gh repo view --json nameWithOwner -q)/releases/tag/v$VERSION${NC}\n"