|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -mkdir -p dist/uve-0.1-linux-x86_64 |
4 | | -cp uve-linux-amd64 dist/uve-0.1-linux-x86_64/uve-bin |
5 | | -cp uve.sh dist/uve-0.1-linux-x86_64/uve.sh |
6 | | -tar -zcvf dist/uve-0.1-linux-x86_64.tgz dist/uve-0.1-linux-x86_64 |
7 | | - |
8 | | -mkdir -p dist/uve-0.1-macos-arm64 |
9 | | -cp uve-darwin-arm64 dist/uve-0.1-macos-arm64/uve-bin |
10 | | -cp uve.sh dist/uve-0.1-macos-arm64/uve.sh |
11 | | -tar -zcvf dist/uve-0.1-macos-arm64.tgz dist/uve-0.1-macos-arm64 |
12 | | - |
13 | | -mkdir -p dist/uve-0.1-macos-x86_64 |
14 | | -cp uve-darwin-amd64 dist/uve-0.1-macos-x86_64/uve-bin |
15 | | -cp uve.sh dist/uve-0.1-macos-x86_64/uve.sh |
16 | | -tar -zcvf dist/uve-0.1-macos-x86_64.tgz dist/uve-0.1-macos-x86_64 |
17 | | - |
18 | | -mkdir -p dist/uve-0.1-windows-x86_64 |
19 | | -cp uve-windows-amd64.exe dist/uve-0.1-windows-x86_64/uve-bin.exe |
20 | | -cp uve.ps1 dist/uve-0.1-windows-x86_64/uve.ps1 |
21 | | -zip -r -X dist/uve-0.1-windows-x86_64.zip dist/uve-0.1-windows-x86_64 |
| 3 | +# Configuration |
| 4 | +VERSION="0.1.2" |
| 5 | +PACKAGE="main.go" |
| 6 | +BINARY_NAME="uve-bin" |
| 7 | +PLATFORMS=("windows/amd64" "linux/amd64" "darwin/amd64" "darwin/arm64") |
| 8 | + |
| 9 | +# Ensure we're in the project root directory |
| 10 | +cd "$(dirname "$0")/.." || exit 1 |
| 11 | + |
| 12 | +echo "=== Building UVE v${VERSION} ===" |
| 13 | + |
| 14 | +# Compile for all platforms |
| 15 | +for platform in "${PLATFORMS[@]}" |
| 16 | +do |
| 17 | + platform_split=(${platform//\// }) |
| 18 | + GOOS=${platform_split[0]} |
| 19 | + GOARCH=${platform_split[1]} |
| 20 | + |
| 21 | + # Set output filename based on platform |
| 22 | + if [ "$GOOS" = "windows" ]; then |
| 23 | + output_name="${BINARY_NAME}-${GOOS}-${GOARCH}.exe" |
| 24 | + else |
| 25 | + output_name="${BINARY_NAME}-${GOOS}-${GOARCH}" |
| 26 | + fi |
| 27 | + |
| 28 | + echo "Building for $GOOS/$GOARCH..." |
| 29 | + env GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o $output_name $PACKAGE |
| 30 | + |
| 31 | + if [ $? -ne 0 ]; then |
| 32 | + echo "Error building for $GOOS/$GOARCH" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | +done |
| 36 | + |
| 37 | +echo "=== Creating release packages ===" |
| 38 | + |
| 39 | +# Create a temporary README.txt with installation instructions |
| 40 | +cat > README.txt << 'EOL' |
| 41 | +UVE - UV Environment Manager |
| 42 | +
|
| 43 | +INSTALLATION: |
| 44 | +
|
| 45 | +Linux/macOS: |
| 46 | +1. Copy uve-bin to a directory in your PATH (e.g., ~/bin/) |
| 47 | +2. Run: uve-bin init |
| 48 | +3. Restart your shell or source your shell config file |
| 49 | +
|
| 50 | +Windows: |
| 51 | +1. Copy uve-bin.exe to a directory in your PATH (e.g., %USERPROFILE%\bin\) |
| 52 | +2. Run: uve-bin.exe init |
| 53 | +3. Start a new PowerShell session or run: Import-Module uve |
| 54 | +
|
| 55 | +For full documentation, visit: https://github.com/robert-mcdermott/uve |
| 56 | +EOL |
| 57 | + |
| 58 | +# Create distribution directories |
| 59 | +mkdir -p dist |
| 60 | + |
| 61 | +# Linux x86_64 |
| 62 | +mkdir -p tmp/uve-${VERSION}-linux-x86_64 |
| 63 | +cp ${BINARY_NAME}-linux-amd64 tmp/uve-${VERSION}-linux-x86_64/${BINARY_NAME} |
| 64 | +cp README.txt tmp/uve-${VERSION}-linux-x86_64/ |
| 65 | +cp LICENSE tmp/uve-${VERSION}-linux-x86_64/ |
| 66 | +tar -zcvf dist/uve-${VERSION}-linux-x86_64.tar.gz -C tmp uve-${VERSION}-linux-x86_64 |
| 67 | + |
| 68 | +# macOS ARM64 |
| 69 | +mkdir -p tmp/uve-${VERSION}-macos-arm64 |
| 70 | +cp ${BINARY_NAME}-darwin-arm64 tmp/uve-${VERSION}-macos-arm64/${BINARY_NAME} |
| 71 | +cp README.txt tmp/uve-${VERSION}-macos-arm64/ |
| 72 | +cp LICENSE tmp/uve-${VERSION}-macos-arm64/ |
| 73 | +tar -zcvf dist/uve-${VERSION}-macos-arm64.tar.gz -C tmp uve-${VERSION}-macos-arm64 |
| 74 | + |
| 75 | +# macOS x86_64 |
| 76 | +mkdir -p tmp/uve-${VERSION}-macos-x86_64 |
| 77 | +cp ${BINARY_NAME}-darwin-amd64 tmp/uve-${VERSION}-macos-x86_64/${BINARY_NAME} |
| 78 | +cp README.txt tmp/uve-${VERSION}-macos-x86_64/ |
| 79 | +cp LICENSE tmp/uve-${VERSION}-macos-x86_64/ |
| 80 | +tar -zcvf dist/uve-${VERSION}-macos-x86_64.tar.gz -C tmp uve-${VERSION}-macos-x86_64 |
| 81 | + |
| 82 | +# Windows x86_64 |
| 83 | +mkdir -p tmp/uve-${VERSION}-windows-x86_64 |
| 84 | +cp ${BINARY_NAME}-windows-amd64.exe tmp/uve-${VERSION}-windows-x86_64/${BINARY_NAME}.exe |
| 85 | +cp README.txt tmp/uve-${VERSION}-windows-x86_64/ |
| 86 | +cp LICENSE tmp/uve-${VERSION}-windows-x86_64/ |
| 87 | +(cd tmp && zip -r -X ../dist/uve-${VERSION}-windows-x86_64.zip uve-${VERSION}-windows-x86_64) |
| 88 | + |
| 89 | +# Generate checksums |
| 90 | +cd dist |
| 91 | +sha256sum *.tar.gz *.zip > SHA256SUMS.txt |
| 92 | +cd .. |
| 93 | + |
| 94 | +# Clean up |
| 95 | +rm -rf tmp |
| 96 | +rm README.txt |
| 97 | +rm ${BINARY_NAME}-* |
| 98 | + |
| 99 | +echo "=== Release packages created in dist/ directory ===" |
| 100 | +echo "Version: ${VERSION}" |
| 101 | +echo "Platforms: ${PLATFORMS[*]}" |
0 commit comments