Skip to content

Commit 5d2170f

Browse files
committed
Update release.yml
1 parent 752526d commit 5d2170f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,31 @@ jobs:
102102
# Get the default branch (usually main or master)
103103
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
104104
105-
# Checkout the default branch
105+
# Save the updated formula content to temp files to prevent loss during checkout
106+
mkdir -p /tmp/formula-updates
107+
if [ -f "Formula/tctl.rb" ]; then
108+
cp Formula/tctl.rb /tmp/formula-updates/
109+
fi
110+
if [ -f "Formula/Versions/tctl@$VERSION.rb" ]; then
111+
cp "Formula/Versions/tctl@$VERSION.rb" /tmp/formula-updates/
112+
fi
113+
114+
# Force checkout the default branch (this will discard any changes)
106115
git fetch origin $DEFAULT_BRANCH
107-
git checkout -B $DEFAULT_BRANCH origin/$DEFAULT_BRANCH
116+
git checkout -f -B $DEFAULT_BRANCH origin/$DEFAULT_BRANCH
117+
118+
# Recreate the formula updates
119+
if [ -f "/tmp/formula-updates/tctl.rb" ]; then
120+
cp /tmp/formula-updates/tctl.rb Formula/tctl.rb
121+
fi
122+
123+
# Ensure the Versions directory exists
124+
mkdir -p Formula/Versions
125+
126+
# Copy back the versioned formula if it exists
127+
if [ -f "/tmp/formula-updates/tctl@$VERSION.rb" ]; then
128+
cp "/tmp/formula-updates/tctl@$VERSION.rb" "Formula/Versions/tctl@$VERSION.rb"
129+
fi
108130
109131
# Now make your changes and commit them
110132
git add Formula/tctl.rb Formula/Versions/tctl@$VERSION.rb

0 commit comments

Comments
 (0)