mirror of
https://github.com/laosb/SwiftTailwind.git
synced 2025-11-28 22:01:38 +00:00
add artifact bundle script
This commit is contained in:
commit
ae6e4e54ec
4 changed files with 127 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/configuration/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
14
Package.swift
Normal file
14
Package.swift
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// swift-tools-version: 5.6
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "SwiftTailwind",
|
||||
platforms: [.macOS(.v12)],
|
||||
products: [
|
||||
.plugin(name: "TailwindCSS", targets: ["TailwindCSS"])
|
||||
],
|
||||
targets: [
|
||||
.plugin(name: "TailwindCSS", capability: .buildTool())
|
||||
]
|
||||
)
|
||||
83
Scripts/buildArtifactBundle.sh
Executable file
83
Scripts/buildArtifactBundle.sh
Executable file
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Check if TAILWINDCSS_VERSION environment variable is set
|
||||
if [[ -z "${TAILWINDCSS_VERSION:-}" ]]; then
|
||||
echo "Error: TAILWINDCSS_VERSION environment variable is not set"
|
||||
echo "Usage: TAILWINDCSS_VERSION=v3.4.0 $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION="$TAILWINDCSS_VERSION"
|
||||
echo "Building artifact bundle for TailwindCSS version: $VERSION"
|
||||
|
||||
# Get the directory containing this script to find the template
|
||||
TEMPLATE_FILE="$PWD/Scripts/info.template.json"
|
||||
|
||||
# Check if template file exists
|
||||
if [[ ! -f "$TEMPLATE_FILE" ]]; then
|
||||
echo "Error: Template file not found at $TEMPLATE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create working directory
|
||||
WORK_DIR="/tmp/tailwindcss.artifactbundle"
|
||||
echo "Creating working directory: $WORK_DIR"
|
||||
rm -rf "$WORK_DIR"
|
||||
mkdir -p "$WORK_DIR"
|
||||
cd "$WORK_DIR"
|
||||
|
||||
# GitHub release base URL
|
||||
BASE_URL="https://github.com/tailwindlabs/tailwindcss/releases/download/$VERSION"
|
||||
|
||||
# Download and place binaries
|
||||
download_binary() {
|
||||
local binary_name="$1"
|
||||
local target_path="$2"
|
||||
local target_dir
|
||||
target_dir=$(dirname "$target_path")
|
||||
|
||||
echo "Downloading $binary_name..."
|
||||
mkdir -p "$target_dir"
|
||||
|
||||
if curl -L "$BASE_URL/$binary_name" > "$target_path"; then
|
||||
chmod +x "$target_path"
|
||||
echo "✓ Downloaded and made executable: $target_path"
|
||||
else
|
||||
echo "✗ Failed to download $binary_name from $BASE_URL/$binary_name"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Download each binary to its target location
|
||||
download_binary "tailwindcss-linux-x64" "tailwindcss-$VERSION-linux-x64/bin/tailwindcss"
|
||||
download_binary "tailwindcss-macos-x64" "tailwindcss-$VERSION-macos-x64/bin/tailwindcss"
|
||||
download_binary "tailwindcss-macos-arm64" "tailwindcss-$VERSION-macos-arm64/bin/tailwindcss"
|
||||
|
||||
# Create info.json from template, replacing %VERSION% with actual version
|
||||
echo "Creating info.json from template..."
|
||||
sed "s/%VERSION%/$VERSION/g" "$TEMPLATE_FILE" > "info.json"
|
||||
echo "✓ Created info.json with version $VERSION"
|
||||
|
||||
# Create ZIP file
|
||||
ZIP_FILE="/tmp/tailwindcss.artifactbundle.zip"
|
||||
echo "Creating ZIP file: $ZIP_FILE"
|
||||
|
||||
# Remove existing ZIP file if it exists
|
||||
rm -f "$ZIP_FILE"
|
||||
|
||||
# Create ZIP with the artifact bundle as the only child in root
|
||||
cd /tmp
|
||||
zip -r "tailwindcss.artifactbundle.zip" "tailwindcss.artifactbundle"
|
||||
|
||||
echo "✓ Created ZIP file: $ZIP_FILE"
|
||||
|
||||
# Compute checksum using Swift Package Manager
|
||||
echo "Computing checksum..."
|
||||
CHECKSUM=$(swift package compute-checksum "$ZIP_FILE")
|
||||
|
||||
echo ""
|
||||
echo "=== BUILD COMPLETE ==="
|
||||
echo "ZIP file path: $ZIP_FILE"
|
||||
echo "Checksum: $CHECKSUM"
|
||||
22
Scripts/info.template.json
Normal file
22
Scripts/info.template.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"schemaVersion": "1.0",
|
||||
"artifacts": {
|
||||
"tailwindcss": {
|
||||
"version": "%VERSION%",
|
||||
"variants": [
|
||||
{
|
||||
"path": "tailwindcss-%VERSION%-macos-x64/bin/tailwindcss",
|
||||
"supportedTriples": ["x86_64-apple-macosx"]
|
||||
},
|
||||
{
|
||||
"path": "tailwindcss-%VERSION%-macos-arm64/bin/tailwindcss",
|
||||
"supportedTriples": ["arm64-apple-macosx"]
|
||||
},
|
||||
{
|
||||
"path": "tailwindcss-%VERSION%-linux-x64/bin/tailwindcss",
|
||||
"supportedTriples": ["x86_64-unknown-linux-gnu"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue