Skip to content

Commit 8e24820

Browse files
committed
feat: adicionar suporte ao modo CI no script de preparação de release
1 parent a99425f commit 8e24820

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

scripts/release/prepare_release.sh

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
set -e
77

8+
# Check if running in CI environment or --ci flag is passed
9+
CI_MODE=false
10+
if [[ "$CI" == "true" ]] || [[ "$GITHUB_ACTIONS" == "true" ]] || [[ "$1" == "--ci" ]]; then
11+
CI_MODE=true
12+
fi
13+
814
# Load shared utilities
915
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1016
source "$SCRIPT_DIR/../utils/version-utils.sh"
@@ -117,10 +123,14 @@ if [ -d ".git" ]; then
117123
warning "There are uncommitted changes:"
118124
git status --porcelain
119125
echo ""
120-
read -p "Continue anyway? (y/N) " -n 1 -r
121-
echo
122-
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
123-
error "Cancelled by user"
126+
if [[ "$CI_MODE" == "true" ]]; then
127+
warning "CI Mode: Continuing with uncommitted changes"
128+
else
129+
read -p "Continue anyway? (y/N) " -n 1 -r
130+
echo
131+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
132+
error "Cancelled by user"
133+
fi
124134
fi
125135
else
126136
info "All files are committed"
@@ -201,22 +211,26 @@ echo " - Packagist: https://packagist.org"
201211
echo " - Documentation: https://pivotphp.com"
202212
echo ""
203213

204-
# 12. Offer to execute useful commands
205-
read -p "Do you want to execute 'composer validate' now? (y/N) " -n 1 -r
206-
echo
207-
if [[ $REPLY =~ ^[Yy]$ ]]; then
208-
composer validate
209-
fi
214+
# 12. Offer to execute useful commands (only in interactive mode)
215+
if [[ "$CI_MODE" == "false" ]]; then
216+
read -p "Do you want to execute 'composer validate' now? (y/N) " -n 1 -r
217+
echo
218+
if [[ $REPLY =~ ^[Yy]$ ]]; then
219+
composer validate
220+
fi
210221

211-
read -p "Do you want to see a preview of what will be included in the package? (y/N) " -n 1 -r
212-
echo
213-
if [[ $REPLY =~ ^[Yy]$ ]]; then
214-
echo "Files that will be included in the package:"
215-
if [ -d ".git" ]; then
216-
git ls-files 2>/dev/null || find . -type f -not -path "./vendor/*" -not -path "./.git/*" -not -path "./node_modules/*"
217-
else
218-
find . -type f -not -path "./vendor/*" -not -path "./.git/*" -not -path "./node_modules/*"
222+
read -p "Do you want to see a preview of what will be included in the package? (y/N) " -n 1 -r
223+
echo
224+
if [[ $REPLY =~ ^[Yy]$ ]]; then
225+
echo "Files that will be included in the package:"
226+
if [ -d ".git" ]; then
227+
git ls-files 2>/dev/null || find . -type f -not -path "./vendor/*" -not -path "./.git/*" -not -path "./node_modules/*"
228+
else
229+
find . -type f -not -path "./vendor/*" -not -path "./.git/*" -not -path "./node_modules/*"
230+
fi
219231
fi
232+
else
233+
info "CI Mode: Skipping interactive commands"
220234
fi
221235

222236
echo ""

0 commit comments

Comments
 (0)