Skip to content

Commit 3621205

Browse files
committed
Update daily_update.yml
1 parent 03c49ce commit 3621205

1 file changed

Lines changed: 66 additions & 15 deletions

File tree

.github/workflows/daily_update.yml

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
- name: Pull latest changes
101101
run: git pull origin main
102102
- name: Install tools
103-
run: sudo apt-get update && sudo apt-get install -y jq tar gzip
103+
run: sudo apt-get update && sudo apt-get install -y jq tar gzip file
104104
- name: Make deamons.sh executable
105105
run: chmod +x deamons.sh
106106
- name: Download and extract binary
@@ -109,37 +109,88 @@ jobs:
109109
run: |
110110
FILE_NAME="${{ matrix.file.file_name }}"
111111
URL="${{ matrix.file.url }}"
112-
wget "$URL" -O bundle.tar.gz
113-
mkdir extracted
114-
tar -xzf bundle.tar.gz -C extracted || true
115-
BIN_PATH=$(find extracted -type f -name 'tor' -o -name 'tor.exe' | head -n 1)
112+
echo "Processing: $FILE_NAME"
113+
114+
# Skip Android and macOS binaries (can't run on Linux)
115+
if [[ "$FILE_NAME" == *"android"* ]] || [[ "$FILE_NAME" == *"macos"* ]]; then
116+
echo "Skipping non-Linux binary: $FILE_NAME"
117+
echo "skip=true" >> $GITHUB_OUTPUT
118+
exit 0
119+
fi
120+
121+
wget -q "$URL" -O bundle.tar.gz
122+
mkdir -p extracted
123+
tar -xzf bundle.tar.gz -C extracted 2>/dev/null || true
124+
125+
# Find tor binary (not tor-gencert, just tor or tor.exe)
126+
BIN_PATH=$(find extracted -type f \( -name 'tor' -o -name 'tor.exe' \) ! -name '*gencert*' ! -name '*resolve*' | head -n 1)
127+
116128
if [ -z "$BIN_PATH" ]; then
117129
echo "No tor binary found in $FILE_NAME"
118-
echo "bin_path=" >> $GITHUB_OUTPUT
130+
echo "Available files:"
131+
find extracted -type f | head -20
132+
echo "skip=true" >> $GITHUB_OUTPUT
119133
exit 0
120134
fi
135+
136+
echo "Found binary: $BIN_PATH"
137+
file "$BIN_PATH"
121138
echo "bin_path=$BIN_PATH" >> $GITHUB_OUTPUT
139+
echo "skip=false" >> $GITHUB_OUTPUT
140+
122141
- name: Extract daemon version
123142
id: daemon
124-
if: steps.extract.outputs.bin_path != ''
143+
if: steps.extract.outputs.skip != 'true'
125144
continue-on-error: true
126145
run: |
127146
BIN_PATH="${{ steps.extract.outputs.bin_path }}"
128-
if [ ! -x "$BIN_PATH" ]; then chmod +x "$BIN_PATH"; fi
129-
DAEMON_VERSION=$(./deamons.sh "$BIN_PATH" || echo "")
147+
echo "Extracting version from: $BIN_PATH"
148+
149+
if [ -z "$BIN_PATH" ]; then
150+
echo "No binary path provided"
151+
exit 0
152+
fi
153+
154+
chmod +x "$BIN_PATH" 2>/dev/null || true
155+
156+
# Run deamons.sh to extract version
157+
DAEMON_VERSION=$(./deamons.sh "$BIN_PATH" 2>&1 || echo "")
158+
159+
echo "Extracted version: '$DAEMON_VERSION'"
160+
161+
if [ -z "$DAEMON_VERSION" ]; then
162+
echo "Failed to extract version"
163+
exit 0
164+
fi
165+
130166
echo "daemon_version=$DAEMON_VERSION" >> $GITHUB_OUTPUT
167+
131168
- name: Update JSON with daemon version
132-
if: steps.daemon.outputs.daemon_version != ''
169+
if: steps.daemon.outputs.daemon_version != '' && steps.extract.outputs.skip != 'true'
133170
run: |
134171
FILE_NAME="${{ matrix.file.file_name }}"
135172
DAEMON_VERSION="${{ steps.daemon.outputs.daemon_version }}"
136-
jq --arg file_name "$FILE_NAME" --arg daemon_version "$DAEMON_VERSION" '(.files[] | select(.file_name == $file_name)).daemon_version = $daemon_version' data/json/latest_export_versions.json > tmp.json && mv tmp.json data/json/latest_export_versions.json
173+
174+
echo "Updating JSON for $FILE_NAME with version $DAEMON_VERSION"
175+
176+
jq --arg file_name "$FILE_NAME" --arg daemon_version "$DAEMON_VERSION" \
177+
'(.files[] | select(.file_name == $file_name)) |= . + {daemon_version: $daemon_version}' \
178+
data/json/latest_export_versions.json > tmp.json && mv tmp.json data/json/latest_export_versions.json
179+
180+
echo "JSON updated successfully"
181+
cat data/json/latest_export_versions.json | jq '.files[] | select(.file_name == "'$FILE_NAME'")'
182+
137183
- name: Commit and push changes
138-
if: steps.daemon.outputs.daemon_version != ''
184+
if: steps.daemon.outputs.daemon_version != '' && steps.extract.outputs.skip != 'true'
139185
run: |
140186
git config --local user.email "action@github.com"
141187
git config --local user.name "GitHub Action"
142188
git add data/json/latest_export_versions.json
143-
git diff --staged --quiet || git commit -m "[Auto] Update daemon version for ${{ matrix.file.file_name }}"
144-
git pull --rebase origin main
145-
git push origin main
189+
190+
if git diff --staged --quiet; then
191+
echo "No changes to commit"
192+
else
193+
git commit -m "[Auto] Update daemon version for ${{ matrix.file.file_name }}"
194+
git pull --rebase origin main || true
195+
git push origin main
196+
fi

0 commit comments

Comments
 (0)