grocy/release.sh
google-labs-jules[bot] ee0561e187 fix: Make release workflow tag trigger more flexible
This commit updates the GitHub Actions workflow for releases to be more flexible.

The workflow will now trigger on tags that follow either the 'v*.*.*' pattern or the '*.*.*' pattern. This allows the user to create releases using tags with or without a 'v' prefix (e.g., 'v1.2.3' or '1.2.3').
2025-08-15 14:19:05 +00:00

70 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Exit on any error
set -e
# --- Config ---
# Get the version from version.json
VERSION=$(grep -o '"version": "[^"]*' version.json | grep -o '[^"]*$')
RELEASE_NAME="grocy"
RELEASE_FILE_NAME="${RELEASE_NAME}_${VERSION}.zip"
RELEASE_BUILD_DIR=".release"
RELEASE_APP_DIR="${RELEASE_BUILD_DIR}/${RELEASE_NAME}"
# ---
echo "▶️ Starting release creation of version ${VERSION}..."
# ---------------------------------------------------------------------------------------------------------
echo "▶️ 1. Initial cleanup..."
rm -f ${RELEASE_FILE_NAME}
rm -rf ${RELEASE_BUILD_DIR}
mkdir -p ${RELEASE_APP_DIR}
# ---------------------------------------------------------------------------------------------------------
echo "▶️ 2. Installing composer dependencies..."
composer install --no-dev --optimize-autoloader
# ---------------------------------------------------------------------------------------------------------
echo "▶️ 3. Installing npm dependencies..."
yarn install
# ---------------------------------------------------------------------------------------------------------
echo "▶️ 4. Copying all application files..."
rsync -av . ${RELEASE_APP_DIR} \
--exclude ".git" \
--exclude ".github" \
--exclude ".gitignore" \
--exclude ".gitattributes" \
--exclude ".devcontainer" \
--exclude ".release" \
--exclude "release.sh" \
--exclude "tests" \
--exclude ".editorconfig" \
--exclude ".php-cs-fixer.php" \
--exclude ".tx" \
--exclude ".vscode" \
--exclude ".yarnrc" \
--exclude "yarn.lock" \
--exclude "package.json" \
--exclude "composer.json" \
--exclude "composer.lock"
# ---------------------------------------------------------------------------------------------------------
echo "▶️ 5. Creating the release ZIP archive..."
cd ${RELEASE_BUILD_DIR}
zip -r ../${RELEASE_FILE_NAME} .
cd ..
# ---------------------------------------------------------------------------------------------------------
echo "▶️ 6. Final cleanup..."
rm -rf ${RELEASE_BUILD_DIR}
# ---------------------------------------------------------------------------------------------------------
echo "✅ Release successfully created: ${RELEASE_FILE_NAME}"