Skip to content

Commit b44054a

Browse files
authored
internal: Develop to main (#55)
* Añadir WTelegramClient como submodule con optimizaciones de transferencia * Configurar Docker y workflows para WTelegramClient submodule + script de cambio completo * Revertir a WTelegramClient NuGet oficial + ordenar carpetas alfabéticamente en DdTree * Añadir workflow de auto-release desde issues
2 parents d542a75 + 919398b commit b44054a

6 files changed

Lines changed: 640 additions & 4 deletions

File tree

.github/workflows/auto-release.yml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: Auto Release from Issue
2+
3+
# Trigger when an issue is opened or labeled with 'release'
4+
on:
5+
issues:
6+
types: [opened, labeled]
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
12+
env:
13+
# Only these users can trigger releases (comma-separated GitHub usernames)
14+
ALLOWED_USERS: "mateof"
15+
16+
jobs:
17+
create-release:
18+
name: Create Release from Issue
19+
runs-on: ubuntu-latest
20+
21+
# Only run if issue has 'release' label
22+
if: contains(github.event.issue.labels.*.name, 'release')
23+
24+
steps:
25+
- name: '🔐 Verify user authorization'
26+
env:
27+
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
28+
run: |
29+
echo "Issue author: $ISSUE_AUTHOR"
30+
echo "Allowed users: $ALLOWED_USERS"
31+
32+
# Check if author is in allowed list
33+
if [[ ! ",$ALLOWED_USERS," == *",$ISSUE_AUTHOR,"* ]]; then
34+
echo "❌ User '$ISSUE_AUTHOR' is not authorized to create releases"
35+
echo " Only these users can create releases: $ALLOWED_USERS"
36+
exit 1
37+
fi
38+
39+
echo "✅ User '$ISSUE_AUTHOR' is authorized"
40+
41+
- name: '📋 Extract version from issue title'
42+
id: version
43+
env:
44+
ISSUE_TITLE: ${{ github.event.issue.title }}
45+
run: |
46+
echo "Issue title: $ISSUE_TITLE"
47+
48+
# Extract version from title (supports: v3.5.0, 3.5.0, v3.5.0.0, 3.5.0.0)
49+
VERSION=$(echo "$ISSUE_TITLE" | grep -oE '[vV]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1)
50+
51+
if [ -z "$VERSION" ]; then
52+
echo "❌ No version found in issue title"
53+
echo " Title should contain a version like: v3.5.0 or 3.5.0"
54+
exit 1
55+
fi
56+
57+
# Remove 'v' prefix if present
58+
VERSION=${VERSION#v}
59+
VERSION=${VERSION#V}
60+
61+
# Ensure 4-part version for csproj (3.5.0 -> 3.5.0.0)
62+
PARTS=$(echo "$VERSION" | tr '.' '\n' | wc -l)
63+
if [ "$PARTS" -eq 3 ]; then
64+
VERSION_CSPROJ="${VERSION}.0"
65+
else
66+
VERSION_CSPROJ="$VERSION"
67+
fi
68+
69+
# Tag version (without trailing .0 if it's 0)
70+
VERSION_TAG="v${VERSION}"
71+
72+
echo "version=$VERSION" >> $GITHUB_OUTPUT
73+
echo "version_csproj=$VERSION_CSPROJ" >> $GITHUB_OUTPUT
74+
echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT
75+
76+
echo "✅ Extracted versions:"
77+
echo " Version: $VERSION"
78+
echo " CSPROJ: $VERSION_CSPROJ"
79+
echo " Tag: $VERSION_TAG"
80+
81+
- name: '📄 Checkout main branch'
82+
uses: actions/checkout@v4
83+
with:
84+
ref: main
85+
fetch-depth: 0
86+
token: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: '🔍 Check if tag already exists'
89+
id: check_tag
90+
run: |
91+
TAG="${{ steps.version.outputs.version_tag }}"
92+
if git rev-parse "$TAG" >/dev/null 2>&1; then
93+
echo "❌ Tag '$TAG' already exists!"
94+
echo "exists=true" >> $GITHUB_OUTPUT
95+
exit 1
96+
fi
97+
echo "✅ Tag '$TAG' does not exist yet"
98+
echo "exists=false" >> $GITHUB_OUTPUT
99+
100+
- name: '📝 Update version in TelegramDownloader.csproj'
101+
run: |
102+
VERSION_CSPROJ="${{ steps.version.outputs.version_csproj }}"
103+
CSPROJ_FILE="TelegramDownloader/TelegramDownloader.csproj"
104+
105+
echo "Updating version in $CSPROJ_FILE to $VERSION_CSPROJ"
106+
107+
# Update <Version> tag
108+
sed -i "s|<Version>[^<]*</Version>|<Version>$VERSION_CSPROJ</Version>|g" "$CSPROJ_FILE"
109+
110+
# Verify the change
111+
echo "Updated content:"
112+
grep -n "Version" "$CSPROJ_FILE" | head -5
113+
114+
echo "✅ Version updated to $VERSION_CSPROJ"
115+
116+
- name: '📝 Update version in TFMAudioApp.csproj (if exists)'
117+
run: |
118+
VERSION_CSPROJ="${{ steps.version.outputs.version_csproj }}"
119+
CSPROJ_FILE="TFMAudioApp/TFMAudioApp.csproj"
120+
121+
if [ -f "$CSPROJ_FILE" ]; then
122+
echo "Updating version in $CSPROJ_FILE to $VERSION_CSPROJ"
123+
124+
# Update <ApplicationDisplayVersion> if exists
125+
if grep -q "ApplicationDisplayVersion" "$CSPROJ_FILE"; then
126+
sed -i "s|<ApplicationDisplayVersion>[^<]*</ApplicationDisplayVersion>|<ApplicationDisplayVersion>${{ steps.version.outputs.version }}</ApplicationDisplayVersion>|g" "$CSPROJ_FILE"
127+
fi
128+
129+
# Update <Version> if exists
130+
if grep -q "<Version>" "$CSPROJ_FILE"; then
131+
sed -i "s|<Version>[^<]*</Version>|<Version>$VERSION_CSPROJ</Version>|g" "$CSPROJ_FILE"
132+
fi
133+
134+
echo "✅ TFMAudioApp version updated"
135+
else
136+
echo "ℹ️ TFMAudioApp.csproj not found, skipping"
137+
fi
138+
139+
- name: '💾 Commit version changes'
140+
run: |
141+
VERSION="${{ steps.version.outputs.version }}"
142+
143+
git config user.name "github-actions[bot]"
144+
git config user.email "github-actions[bot]@users.noreply.github.com"
145+
146+
git add -A
147+
148+
# Check if there are changes to commit
149+
if git diff --staged --quiet; then
150+
echo "ℹ️ No version changes to commit (version may already be set)"
151+
else
152+
git commit -m "Bump version to $VERSION"
153+
git push origin main
154+
echo "✅ Version changes committed and pushed"
155+
fi
156+
157+
- name: '🏷️ Create and push tag'
158+
run: |
159+
TAG="${{ steps.version.outputs.version_tag }}"
160+
161+
git tag -a "$TAG" -m "Release $TAG"
162+
git push origin "$TAG"
163+
164+
echo "✅ Tag '$TAG' created and pushed"
165+
166+
- name: '🚀 Create GitHub Release'
167+
env:
168+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169+
run: |
170+
TAG="${{ steps.version.outputs.version_tag }}"
171+
VERSION="${{ steps.version.outputs.version }}"
172+
ISSUE_BODY="${{ github.event.issue.body }}"
173+
174+
# Create release with issue body as release notes
175+
gh release create "$TAG" \
176+
--title "Release $TAG" \
177+
--notes "## What's Changed
178+
179+
$ISSUE_BODY
180+
181+
---
182+
*Release created automatically from issue #${{ github.event.issue.number }}*" \
183+
--target main
184+
185+
echo "✅ GitHub Release created"
186+
187+
- name: '✅ Close issue with success comment'
188+
env:
189+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
190+
run: |
191+
TAG="${{ steps.version.outputs.version_tag }}"
192+
193+
gh issue comment ${{ github.event.issue.number }} --body "## ✅ Release Created Successfully!
194+
195+
- **Version:** $TAG
196+
- **CSPROJ Version:** ${{ steps.version.outputs.version_csproj }}
197+
- **Release:** https://github.com/${{ github.repository }}/releases/tag/$TAG
198+
199+
The build workflow has been triggered and will upload the binaries shortly.
200+
201+
---
202+
*This issue was automatically processed by the release workflow.*"
203+
204+
gh issue close ${{ github.event.issue.number }} --reason completed
205+
206+
echo "✅ Issue closed"
207+
208+
- name: '❌ Comment on failure'
209+
if: failure()
210+
env:
211+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212+
run: |
213+
gh issue comment ${{ github.event.issue.number }} --body "## ❌ Release Failed
214+
215+
The release process encountered an error. Please check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
216+
217+
Common issues:
218+
- Version format incorrect (use: v3.5.0 or 3.5.0)
219+
- Tag already exists
220+
- User not authorized
221+
222+
---
223+
*This comment was automatically generated.*"

.github/workflows/buildrelease.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
steps:
5757
- name: '📄 Checkout'
5858
uses: actions/checkout@v4
59+
with:
60+
submodules: recursive
5961

6062
- name: '🔧 Setup .NET 10'
6163
uses: actions/setup-dotnet@v4

TelegramDownloader/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ RUN python3 -m venv /app/venv && \
5151
ENV PATH="/app/venv/bin:${PATH}"
5252

5353
COPY --from=publish /app/publish .
54-
ENTRYPOINT ["dotnet", "TelegramDownloader.dll"]
54+
ENTRYPOINT ["dotnet", "TelegramDownloader.dll"]

TelegramDownloader/Shared/Ddtree.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
}
8787
}
8888

89-
return Task.FromResult(result);
89+
// Sort alphabetically ascending
90+
return Task.FromResult(result.OrderBy(x => x.Name).ToList());
9091
}
9192

9293
private async Task<List<TreeNodeModel>> LoadTelegramFolders(string dbName, string parentId)
@@ -115,7 +116,8 @@
115116
HasChildren = f.HasChild
116117
});
117118
}
118-
return result;
119+
// Sort alphabetically ascending
120+
return result.OrderBy(x => x.Name).ToList();
119121
}
120122

121123
private async Task OnFolderSelected(string value)

TelegramDownloader/TelegramDownloader.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<Version>3.4.0.0</Version>

0 commit comments

Comments
 (0)