|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +#!/usr/bin/env bash |
| 4 | + |
| 5 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 6 | +# or more contributor license agreements. See the NOTICE file |
| 7 | +# distributed with this work for additional information |
| 8 | +# regarding copyright ownership. The ASF licenses this file |
| 9 | +# to you under the Apache License, Version 2.0 (the |
| 10 | +# "License"); you may not use this file except in compliance |
| 11 | +# with the License. You may obtain a copy of the License at |
| 12 | +# |
| 13 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +# |
| 15 | +# Unless required by applicable law or agreed to in writing, |
| 16 | +# software distributed under the License is distributed on an |
| 17 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 18 | +# KIND, either express or implied. See the License for the |
| 19 | +# specific language governing permissions and limitations |
| 20 | +# under the License. |
| 21 | + |
| 22 | +# This script is used to generate Cross.toml file for user which executes |
| 23 | +# this script. This is needed since Cross.toml build.dockerfile.build-args |
| 24 | +# section requires statically defined Docker build arguments and parameters |
| 25 | +# like current UID or GID must be entered (cannot be generated or fetched |
| 26 | +# during cross execution time). |
| 27 | + |
| 28 | +set -euo pipefail |
| 29 | + |
| 30 | +# Determine tar command based on OS |
| 31 | +TAR_CMD="tar" |
| 32 | +OS_NAME=$(uname) |
| 33 | + |
| 34 | +if [[ "$OS_NAME" == "Darwin" ]]; then |
| 35 | + if command -v gtar >/dev/null 2>&1; then |
| 36 | + TAR_CMD="gtar" |
| 37 | + else |
| 38 | + echo "❌ GNU tar (gtar) is required on macOS. Install it with: brew install gnu-tar" |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | +fi |
| 42 | + |
| 43 | +if [ "$(basename "$PWD")" == "scripts" ]; then |
| 44 | + cd .. |
| 45 | +fi |
| 46 | + |
| 47 | +SRC_DIR="./" |
| 48 | +RELEASE_DIR="iggy_release" |
| 49 | +TEMP_DIR="iggy_release_tmp" |
| 50 | + |
| 51 | +rm -rf "$TEMP_DIR" |
| 52 | +rm -rf "$RELEASE_DIR" |
| 53 | +mkdir -p "$TEMP_DIR" |
| 54 | +mkdir -p "$RELEASE_DIR" |
| 55 | + |
| 56 | +FILES=( |
| 57 | + "Cargo.lock" |
| 58 | + "Cargo.toml" |
| 59 | + "DEPENDENCIES.md" |
| 60 | + "DISCLAIMER" |
| 61 | + "Dockerfile" |
| 62 | + "LICENSE" |
| 63 | + "NOTICE" |
| 64 | + "docker-compose.yml" |
| 65 | + "justfile" |
| 66 | +) |
| 67 | + |
| 68 | +DIRS=( |
| 69 | + "bench" |
| 70 | + "certs" |
| 71 | + "cli" |
| 72 | + "configs" |
| 73 | + "examples" |
| 74 | + "integration" |
| 75 | + "licenses" |
| 76 | + "scripts" |
| 77 | + "sdk" |
| 78 | + "server" |
| 79 | + "tools" |
| 80 | +) |
| 81 | + |
| 82 | +for file in "${FILES[@]}"; do |
| 83 | + cp "$SRC_DIR/$file" "$TEMP_DIR/" |
| 84 | +done |
| 85 | + |
| 86 | +for dir in "${DIRS[@]}"; do |
| 87 | + cp -r "$SRC_DIR/$dir" "$TEMP_DIR/" |
| 88 | +done |
| 89 | + |
| 90 | +VERSION=$(grep '^version' "$TEMP_DIR/server/Cargo.toml" | head -n 1 | cut -d '"' -f2) |
| 91 | + |
| 92 | +echo "Preparing release for version: $VERSION" |
| 93 | + |
| 94 | +ARCHIVE_NAME="iggy-${VERSION}-incubating-src.tar.gz" |
| 95 | + |
| 96 | +GZIP=-n "$TAR_CMD" --sort=name \ |
| 97 | + --mtime='UTC 2020-01-01' \ |
| 98 | + --owner=0 --group=0 --numeric-owner \ |
| 99 | + -czf "$ARCHIVE_NAME" -C "$TEMP_DIR" . |
| 100 | + |
| 101 | +CHECKSUM_FILE="${ARCHIVE_NAME}.sha512" |
| 102 | +sha512sum "$ARCHIVE_NAME" > "$CHECKSUM_FILE" |
| 103 | + |
| 104 | +rm -rf "$TEMP_DIR" |
| 105 | + |
| 106 | +echo "Release directory: $RELEASE_DIR" |
| 107 | +echo "SHA-512 checksum:" |
| 108 | +cat "$CHECKSUM_FILE" |
| 109 | +echo "✔ Archive created: $ARCHIVE_NAME" |
| 110 | +echo "✔ Checksum saved to: $CHECKSUM_FILE" |
| 111 | + |
| 112 | +mv "$ARCHIVE_NAME" "$RELEASE_DIR/" |
| 113 | +mv "$CHECKSUM_FILE" "$RELEASE_DIR/" |
| 114 | + |
| 115 | + |
0 commit comments