From e392f435a5f6b413c5b6b8326a2a146c6dee669d Mon Sep 17 00:00:00 2001 From: Kotokaze <62094392+kotokaze@users.noreply.github.com> Date: Fri, 24 Mar 2023 21:57:40 +0900 Subject: [PATCH] :white_check_mark: Cache versioning (#14) * :sparkles: Get releae number internally * :sparkles: Add release number to cache * :white_check_mark: Shorten cache name * :white_check_mark: Restore from shortened name * :warning: Fix typo in cache name * Revert ":warning: Fix typo in cache name" This reverts commit 03d53695fe38b5708cf0019233252558c8a40f1b. Revert ":white_check_mark: Restore from shortened name" This reverts commit 6fe508421e8667482e2f037b38b930710113bd99. Revert ":white_check_mark: Shorten cache name" This reverts commit efe98d38230ee1abf8895faf13c311a304642baf. --- .github/workflows/publish.yml | 27 +++++++++++++++++---------- Dockerfile | 5 +++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b28ba2a..213fef8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,6 +32,12 @@ 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 📦 @@ -39,8 +45,10 @@ jobs: 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 @@ -55,6 +63,12 @@ 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 💾 @@ -62,7 +76,7 @@ jobs: 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 @@ -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 💻 @@ -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 }} diff --git a/Dockerfile b/Dockerfile index e1b6aa3..e9ba8ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \