Skip to content

Commit

Permalink
✅ Cache versioning (#14)
Browse files Browse the repository at this point in the history
* ✨ Get releae number internally

* ✨ Add release number to cache

* ✅ Shorten cache name

* ✅ Restore from shortened name

* ⚠️ Fix typo in cache name

* Revert "⚠️ Fix typo in cache name"

This reverts commit 03d5369.

Revert ":white_check_mark: Restore from shortened name"

This reverts commit 6fe5084.

Revert ":white_check_mark: Shorten cache name"

This reverts commit efe98d3.
  • Loading branch information
kotokaze authored Mar 24, 2023
1 parent 05046f5 commit e392f43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,23 @@ jobs:
with:
fetch-depth: 1

# Get current year
- name: Get current year 📅
id: get-year
shell: bash
run: echo "year=$(date +%Y)" >> ${GITHUB_OUTPUT}

# Restore cached repository
# https://github.com/actions/cache/tree/main/restore
- name: Restore cached repository 📦
id: restore
uses: actions/cache/restore@v3
with:
path: texlive/
key: rsync-${{ github.sha }}
restore-keys: rsync-
key: rsync-TL${{ steps.get-year.outputs.year }}-${{ github.sha }}
restore-keys: |
rsync-TL${{ steps.get-year.outputs.year }}-
rsync-
enableCrossOsArchive: true
fail-on-cache-miss: false

Expand All @@ -55,14 +63,20 @@ jobs:
tree -nh texlive/
echo "::endgroup::"
# Get the release version of the repository
- name: Get TeX Live release version 🔖
id: tl-release
shell: bash
run: echo "number=$(find ${{ github.workspace }}/texlive/ -name 'TEXLIVE_*' -print0 | sed -e s/[^0-9]//g)" >> ${GITHUB_OUTPUT}

# Save repository to cache
# https://github.com/actions/cache/tree/main/save
- name: Save repository to cache 💾
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
uses: actions/cache/save@v3
with:
path: texlive/
key: rsync-${{ github.sha }}
key: rsync-TL${{ steps.tl-release.outputs.number }}-${{ github.sha }}
enableCrossOsArchive: true

# Workaround: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
Expand All @@ -77,12 +91,6 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Get the release version of the repository
- name: Get TeX Live release version 🔖
id: tl-release
shell: bash
run: echo "number=$(find ${{ github.workspace }}/texlive/ -name 'TEXLIVE_*' -print0 | sed -e s/[^0-9]//g)" >> ${GITHUB_OUTPUT}

# Add support for more platforms with QEMU
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU 💻
Expand Down Expand Up @@ -198,7 +206,6 @@ jobs:
docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
set: |
*.args.RELEASE=${{ steps.tl-release.outputs.number }}
*.cache-to=type=registry,mode=max,ref=${{ env.GHCR }}/${{ github.repository }}:buildcache,oci-mediatypes=true
*.cache-from=type=registry,ref=${{ env.GHCR }}/${{ github.repository }}:buildcache
*.platform=${{ steps.get-platforms.outputs.platform }}
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ RUN if [ ! -d texlive ] \
;fi \
&& cd texlive \
&& perl ./install-tl -profile ../texlive.installation.profile --no-interaction \
&& mv TEXLIVE_* ../ \
&& cd .. \
&& rm -rf texlive

# Create dummy package with equivs and generate cache
ARG RELEASE
RUN (curl -sLf "https://tug.org/texlive/files/debian-equivs-"${RELEASE}"-ex.txt" || curl -sSLf "https://tug.org/texlive/files/debian-equivs-"$((${RELEASE}-1))"-ex.txt" ) \
RUN RELEASE=$(find -name 'TEXLIVE_*' -print0 | sed -e s/[^0-9]//g) \
&& (curl -sLf "https://tug.org/texlive/files/debian-equivs-"${RELEASE}"-ex.txt" || curl -sSLf "https://tug.org/texlive/files/debian-equivs-"$((${RELEASE}-1))"-ex.txt" ) \
| sed -e "/^Version:\ /s/"${RELEASE}"/9999/" -e "/^Version:\ /s/"$((${RELEASE}-1))"/9999/" -e "/^Depends:\ freeglut3$/d" \
| equivs-build - \
&& dpkg -i texlive-local_9999.99999999-1_all.deb \
Expand Down

0 comments on commit e392f43

Please sign in to comment.