Skip to content

Commit

Permalink
Improve versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Aug 23, 2024
1 parent 0ca2a9e commit 62ed9e4
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 41 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/configure_from_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/python

import sys
import urllib.request
import re
import os

TL_MIRROR = 'https://www.texlive.info/tlnet-archive/{}/{}/{}/tlnet/'


def github_output(variable, value):
line = f'{variable}={value}'
print(line)
if 'GITHUB_OUTPUT' in os.environ:
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(line + '\n')


def get_tl_year(mirror):
listing = urllib.request.urlopen(mirror).read().decode('utf-8')
matches = re.findall('>TEXLIVE_([\\d]+)<', listing)
return int(matches[0])


def main():
date = sys.argv[1]

year = date[0:4]
month = date[4:6]
day = date[6:8]

mirror = TL_MIRROR.format(year, month, day)

tl_year = get_tl_year(mirror)

versions = [f'{tl_year}-latest', f'{tl_year}-{date}']
versions = ' '.join(versions)

github_output('MIRROR', mirror)
github_output('VERSIONS', versions)


if __name__ == '__main__':
main()
109 changes: 68 additions & 41 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,79 @@ on:
schedule:
- cron: '12 4 * * *'
workflow_dispatch:
date:
version:
required: false
type: string
description: The date used as a version, YYYYMMDD
push:
required: true
type: boolean
description: Whether to push built images to repositories

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Prepare configuration
run: |
IMAGE_ID=${{ github.repository_owner }}/latex
echo IMAGE_ID=$IMAGE_ID
echo "IMAGE_ID=${IMAGE_ID}" >> $GITHUB_ENV
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION=$(date '+%Y%m%d')
TL_MIRROR="https://www.texlive.info/tlnet-archive/$(date '+%Y')/$(date '+%m')/$(date '+%d')/tlnet/"
echo Using daily version: $VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo Using mirror: TL_MIRROR
echo "TL_MIRROR=${TL_MIRROR}" >> $GITHUB_ENV
echo "PUSH=true" >> $GITHUB_ENV
if [[ "${{ github.event_name }}" == "schedule" ]]; then
DATE=$(date '+%Y%m%d')
PUSH="true"
echo "Running scheduled build with date: $DATE"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ -n "${{ inputs.date }}" ]]; then
DATE="${{ inputs.date }}"
else
DATE=$(date '+%Y%m%d')
echo "No date supplied, using today's date"
fi
if [[ "${{ inputs.push }}" == "true" ]]; then
PUSH="true"
else
PUSH="false"
fi
echo "Running manual build with date: $DATE, push: $PUSH"
elif [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
PUSH="true"
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $REF_NAME | sed -e 's/^v//')
VERSION_YEAR=$(echo $VERSION | sed -e 's/[^0-9].*//')
. MIRRORS
echo Using version from tag: $VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "PUSH=true" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
VERSION=latest
variable=TL_MIRROR_${VERSION_YEAR}
MIRROR=${!variable}
echo Using version based on main: $VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "PUSH=true" >> $GITHUB_ENV
if [[ -z "$MIRROR" ]]; then
echo "Mirror not found for $VERSION_YEAR ($VERSION)"
exit 1
fi
echo "Running build for tag with version: $VERSION"
else
VERSION=$(git rev-parse --short HEAD)
DATE=$(date '+%Y%m%d')
PUSH="false"
echo "Running test build with date: $DATE"
fi
# Will be re-tagged before push
echo "IMAGE_ID=image" | tee -a $GITHUB_OUTPUT
echo "VERSION=version" | tee -a $GITHUB_OUTPUT
echo Using version based on commit hash: $VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "IMAGE_IDS=$IMAGE_ID ghcr.io/$IMAGE_ID" | tee -a $GITHUB_OUTPUT
echo "PUSH=$PUSH" | tee -a $GITHUB_OUTPUT
if [[ -n "$VERSION" ]]; then
echo "MIRROR=$MIRROR" | tee -a $GITHUB_OUTPUT
echo "VERSIONS=$VERSION" | tee -a $GITHUB_OUTPUT
else
./.github/workflows/configure_from_date.py "$DATE"
fi
- name: Build minimal
Expand Down Expand Up @@ -95,21 +129,14 @@ jobs:
- name: Push images
if: env.PUSH == 'true'
run: |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-small
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-full
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-small ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-small
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-full ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-full
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }} ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-small
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-full
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}
for image_id in $IMAGE_IDS; do
for version in $VERSIONS; do
for suffix in "-minimal" "-basic" "-small" "-medium" "-full" "" ; do
image=${image_id}:${version}${suffix}
echo "Tagging and pushing ${image}..."
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}${suffix} ${image}
docker push ${image}
done
done
done
29 changes: 29 additions & 0 deletions MIRRORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file contains mirrors for the final TL versions.
# Using these mirrors instead of the main TeX Live mirror ensures that:
# 1. tlmgr may still be used even if a version is historic, and
# 2. historic versions may still be built.

# Note: There are alternative historic mirrors outside of US,
# but US mirrors are used here as GH runners are US-based.
# See https://tug.org/historic/ for details.

# Final historic releases
TL_MIRROR_2008=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2008/tlnet/
TL_MIRROR_2009=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2009/tlnet/
TL_MIRROR_2010=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2010/tlnet/
TL_MIRROR_2011=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2011/tlnet-final/
TL_MIRROR_2012=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2012/tlnet-final/
TL_MIRROR_2013=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2013/tlnet-final/
TL_MIRROR_2014=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2014/tlnet-final/
TL_MIRROR_2015=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2015/tlnet-final/
TL_MIRROR_2016=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2016/tlnet-final/
TL_MIRROR_2017=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2017/tlnet-final/
TL_MIRROR_2018=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2018/tlnet-final/
TL_MIRROR_2019=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2019/tlnet-final/
TL_MIRROR_2020=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2020/tlnet-final/
TL_MIRROR_2021=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2021/tlnet-final/
TL_MIRROR_2022=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2022/tlnet-final/
TL_MIRROR_2023=https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2023/tlnet-final/

# Current release in progress
TL_MIRROR_2024=https://texlive.info/tlnet-archive/2024/08/23/tlnet/

0 comments on commit 62ed9e4

Please sign in to comment.