Skip to content

Commit f0bced7

Browse files
committed
Add configurable CTAN repository with validation and version detection
Allow manual workflow runs to specify CTAN mirror via workflow_dispatch input. Validate repository accessibility and detect TeX Live version before build starts. Include repository URL and version in release notes for tracking yearly updates. This will help with situation like #50 were some mirrors may not be updated
1 parent 30813a1 commit f0bced7

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

.github/workflows/build.yaml

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
on:
22
workflow_dispatch:
3+
inputs:
4+
ctan_repo:
5+
description: 'CTAN repository URL (e.g., https://ctan.math.illinois.edu/systems/texlive/tlnet). See https://ctan.org/mirrors/mirmon for available mirrors.'
6+
required: false
7+
type: string
8+
default: 'https://ctan.math.illinois.edu/systems/texlive/tlnet'
39
schedule:
410
- cron: '5 3 * * *'
511

@@ -11,9 +17,68 @@ env:
1117
# required for GH to run on another repo (-R option)
1218
# https://cli.github.com/manual/gh_help_environment
1319
GH_REPO: rstudio/tinytex-releases
20+
# CTAN repository URL for TeX Live packages
21+
CTAN_REPO: ${{ inputs.ctan_repo || 'https://ctan.math.illinois.edu/systems/texlive/tlnet' }}
1422

1523
jobs:
24+
validate-ctan:
25+
runs-on: ubuntu-latest
26+
name: Validate CTAN repository
27+
outputs:
28+
texlive-year: ${{ steps.check-repo.outputs.texlive-year }}
29+
steps:
30+
- name: Check CTAN repository accessibility
31+
id: check-repo
32+
run: |
33+
echo "Validating CTAN repository: $CTAN_REPO"
34+
35+
# Check if the repository is accessible by fetching the texlive.tlpdb file
36+
if ! curl --fail --silent --show-error --head "$CTAN_REPO/tlpkg/texlive.tlpdb" > /dev/null; then
37+
echo "✗ CTAN repository is not accessible or invalid"
38+
echo "Please check the URL: $CTAN_REPO"
39+
exit 1
40+
fi
41+
42+
echo "✓ CTAN repository is valid and accessible"
43+
44+
# Detect TeX Live version by checking for TEXLIVE_YYYY files
45+
echo "Detecting TeX Live version..."
46+
CURRENT_YEAR=$(date +%Y)
47+
TEXLIVE_YEAR=""
48+
49+
# Check current year first, then previous year
50+
for year in $CURRENT_YEAR $((CURRENT_YEAR - 1)); do
51+
if curl --fail --silent --show-error --head "$CTAN_REPO/TEXLIVE_$year" > /dev/null 2>&1; then
52+
TEXLIVE_YEAR=$year
53+
break
54+
fi
55+
done
56+
57+
if [ -n "$TEXLIVE_YEAR" ]; then
58+
echo "✓ TeX Live version: $TEXLIVE_YEAR"
59+
echo "texlive-year=$TEXLIVE_YEAR" >> $GITHUB_OUTPUT
60+
else
61+
echo "⚠ Could not detect version with current/previous year, checking older versions..."
62+
# Check for older TEXLIVE_YYYY files (going back 5 years)
63+
for offset in {2..5}; do
64+
year=$((CURRENT_YEAR - offset))
65+
if curl --fail --silent --show-error --head "$CTAN_REPO/TEXLIVE_$year" > /dev/null 2>&1; then
66+
TEXLIVE_YEAR=$year
67+
break
68+
fi
69+
done
70+
71+
if [ -n "$TEXLIVE_YEAR" ]; then
72+
echo "✓ TeX Live version: $TEXLIVE_YEAR"
73+
echo "texlive-year=$TEXLIVE_YEAR" >> $GITHUB_OUTPUT
74+
else
75+
echo "⚠ Warning: Could not detect TeX Live version (no TEXLIVE_YYYY file found)"
76+
echo "texlive-year=unknown" >> $GITHUB_OUTPUT
77+
fi
78+
fi
79+
1680
new-release:
81+
needs: [validate-ctan]
1782
runs-on: ubuntu-latest
1883
name: Create new daily draft release
1984
outputs:
@@ -35,7 +100,6 @@ jobs:
35100
name: Build Bundles For Windows
36101

37102
env:
38-
CTAN_REPO: https://ctan.math.illinois.edu/systems/texlive/tlnet
39103
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
40104

41105
steps:
@@ -111,7 +175,6 @@ jobs:
111175
tlmgr-version: ${{ steps.tlmgr-version.outputs.TLMGR_VERSION }}
112176

113177
env:
114-
CTAN_REPO: https://ctan.math.illinois.edu/systems/texlive/tlnet
115178
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
116179

117180
steps:
@@ -213,7 +276,6 @@ jobs:
213276
name: Build Bundles For macOS
214277

215278
env:
216-
CTAN_REPO: https://ctan.math.illinois.edu/systems/texlive/tlnet
217279
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
218280

219281
steps:
@@ -322,7 +384,7 @@ jobs:
322384
gh release upload ${{needs.new-release.outputs.draft-tag}} tinitex.zip tinitex.tgz tinitex.tar.gz --clobber
323385
324386
deploy:
325-
needs: [new-release, build-windows, build-linux, build-mac, tinitex]
387+
needs: [validate-ctan, new-release, build-windows, build-linux, build-mac, tinitex]
326388
runs-on: ubuntu-latest
327389
name: Publish new daily release
328390

@@ -339,6 +401,12 @@ jobs:
339401
${{ needs.build-linux.outputs.tlmgr-version }}
340402
EOF
341403
echo '```' >> notes.md
404+
echo "" >> notes.md
405+
if [ "${{ needs.validate-ctan.outputs.texlive-year }}" != "unknown" ]; then
406+
echo "Built from CTAN repository: \`$CTAN_REPO\` (TeX Live ${{ needs.validate-ctan.outputs.texlive-year }})" >> notes.md
407+
else
408+
echo "Built from CTAN repository: \`$CTAN_REPO\`" >> notes.md
409+
fi
342410
343411
- name: Publish new release
344412
run: |

0 commit comments

Comments
 (0)