]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move shared code to composite actions.
authorMika Lindqvist <postmaster@raasu.org>
Thu, 7 May 2026 21:28:46 +0000 (00:28 +0300)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 10 May 2026 13:05:47 +0000 (15:05 +0200)
.github/actions/restore-apt-cache/action.yml [new file with mode: 0644]
.github/actions/update-apt-cache/action.yml [new file with mode: 0644]
.github/workflows/cmake.yml
.github/workflows/configure.yml

diff --git a/.github/actions/restore-apt-cache/action.yml b/.github/actions/restore-apt-cache/action.yml
new file mode 100644 (file)
index 0000000..65c1d5a
--- /dev/null
@@ -0,0 +1,44 @@
+name: Restore APT cache
+description: Restores cached .deb packages for APT
+inputs:
+  packages:
+    description: Packages to cache
+    required: true
+  cache-key:
+    description: Cache key to use
+    required: true
+outputs:
+  cache-hit:
+    description: A boolean value to indicate an exact match was found for the primary key
+    value: ${{ steps.load-cache.outputs.cache-hit }}
+runs:
+  using: "composite"
+  steps:
+    - name: Get cache key (Ubuntu)
+      if: runner.os == 'Linux'
+      id: get-ubuntu-cache-key
+      shell: bash
+      run: |
+        echo "release=$(sed -n 's/UBUNTU_CODENAME=\(.*\)/\1/p' /etc/os-release)" >> $GITHUB_OUTPUT
+        echo "pkg_sig=$(printf '%s' "${{ inputs.packages }}" | sha256sum | cut -c1-12)" >> $GITHUB_OUTPUT
+        echo "key=$(/bin/date -u "+%G%V")" >> $GITHUB_OUTPUT
+
+    - name: Load package cache (Ubuntu)
+      if: runner.os == 'Linux'
+      id: load-cache
+      uses: actions/cache@v5
+      with:
+        path: ${{ runner.temp }}/apt-archives/*.deb
+        key: cache-apt-${{ inputs.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}-${{ steps.get-ubuntu-cache-key.outputs.pkg_sig }}-${{ steps.get-ubuntu-cache-key.outputs.key }}
+        restore-keys: |
+          cache-apt-${{ inputs.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}-${{ steps.get-ubuntu-cache-key.outputs.pkg_sig }}
+          cache-apt-${{ inputs.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}
+
+    - name: Restore cached packages (Ubuntu)
+      if: runner.os == 'Linux'
+      shell: bash
+      run: |
+        sudo mkdir -p /var/cache/apt/archives ${{ runner.temp }}/apt-archives
+        if compgen -G "${{ runner.temp }}/apt-archives/*.deb" > /dev/null; then
+          sudo mv -f ${{ runner.temp }}/apt-archives/*.deb /var/cache/apt/archives/
+        fi
diff --git a/.github/actions/update-apt-cache/action.yml b/.github/actions/update-apt-cache/action.yml
new file mode 100644 (file)
index 0000000..e8ec342
--- /dev/null
@@ -0,0 +1,14 @@
+name: Update APT cache
+description: Updates list of cached .deb packages for APT
+runs:
+  using: "composite"
+  steps:
+    - name: Update package cache (Ubuntu)
+      if: runner.os == 'Linux'
+      shell: bash
+      run: |
+        if compgen -G "/var/cache/apt/archives/*.deb" > /dev/null; then
+          sudo apt autoclean
+          sudo apt autoremove
+          sudo cp -f /var/cache/apt/archives/*.deb ${{ runner.temp }}/apt-archives/
+        fi
index f390de75dd7654c5c43840cda85e15150ab56c2a..d6dfc4865cc21f7f3646b9c3f3b01d53539d3db9 100644 (file)
@@ -759,33 +759,13 @@ jobs:
         curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
         sudo sed -i 's#http://azure.archive.ubuntu.com/ubuntu/#mirror+file:/etc/apt/mirrors.txt#' /etc/apt/sources.list
 
-    - name: Get cache key (Ubuntu)
-      if: runner.os == 'Linux' && matrix.packages && !contains(matrix.os, 'z15')
-      id: get-ubuntu-cache-key
-      shell: bash
-      run: |
-        echo "release=$(sed -n 's/UBUNTU_CODENAME=\(.*\)/\1/p' /etc/os-release)" >> $GITHUB_OUTPUT
-        pkg='${{ matrix.packages }}'
-        echo "pkg_sig=$(printf '%s' "$pkg" | sha256sum | cut -c1-12)" >> $GITHUB_OUTPUT
-        echo "key=$(/bin/date -u "+%G%V")" >> $GITHUB_OUTPUT
-
-    - name: Load package cache (Ubuntu)
-      if: runner.os == 'Linux' && matrix.packages && !contains(matrix.os, 'z15')
-      uses: actions/cache@v5
-      with:
-        path: ${{ runner.temp }}/apt-archives/*.deb
-        key: cache-apt-${{ matrix.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}-${{ steps.get-ubuntu-cache-key.outputs.pkg_sig }}-${{ steps.get-ubuntu-cache-key.outputs.key }}
-        restore-keys: |
-          cache-apt-${{ matrix.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}-${{ steps.get-ubuntu-cache-key.outputs.pkg_sig }}
-          cache-apt-${{ matrix.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}
-
     - name: Restore cached packages (Ubuntu)
       if: runner.os == 'Linux' && matrix.packages && !contains(matrix.os, 'z15')
-      run: |
-        sudo mkdir -p /var/cache/apt/archives ${{ runner.temp }}/apt-archives
-        if compgen -G "${{ runner.temp }}/apt-archives/*.deb" > /dev/null; then
-          sudo mv -f ${{ runner.temp }}/apt-archives/*.deb /var/cache/apt/archives/
-        fi
+      id: restore-apt-cache
+      uses: ./.github/actions/restore-apt-cache
+      with:
+        packages: ${{ matrix.packages }}
+        cache-key: ${{ matrix.cache-key }}
 
     - name: Install packages (Ubuntu)
       if: runner.os == 'Linux' && !contains(matrix.os, 'z15')
@@ -795,13 +775,8 @@ jobs:
             ${{ matrix.packages || 'libgtest-dev libbenchmark-dev' }}
 
     - name: Update package cache (Ubuntu)
-      if: runner.os == 'Linux' && matrix.packages && !contains(matrix.os, 'z15')
-      run: |
-        if compgen -G "/var/cache/apt/archives/*.deb" > /dev/null; then
-          sudo apt autoclean
-          sudo apt autoremove
-          sudo cp -f /var/cache/apt/archives/*.deb ${{ runner.temp }}/apt-archives/
-        fi
+      if: runner.os == 'Linux' && matrix.packages && !contains(matrix.os, 'z15') && steps.restore-apt-cache.outputs.cache-hit != 'true'
+      uses: ./.github/actions/update-apt-cache
 
     - name: Install packages (Windows)
       if: runner.os == 'Windows'
index 8fd345e159a2b74fb3e1553326f88541f43a10d2..000ab80ae683df0c3ab42b31c7566f1f0ff2100a 100644 (file)
@@ -310,33 +310,13 @@ jobs:
         curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
         sudo sed -i 's#http://azure.archive.ubuntu.com/ubuntu/#mirror+file:/etc/apt/mirrors.txt#' /etc/apt/sources.list
 
-    - name: Get cache key (Ubuntu)
-      if: runner.os == 'Linux' && matrix.packages
-      id: get-ubuntu-cache-key
-      shell: bash
-      run: |
-        echo "release=$(sed -n 's/UBUNTU_CODENAME=\(.*\)/\1/p' /etc/os-release)" >> $GITHUB_OUTPUT
-        pkg='${{ matrix.packages }}'
-        echo "pkg_sig=$(printf '%s' "$pkg" | sha256sum | cut -c1-12)" >> $GITHUB_OUTPUT
-        echo "key=$(/bin/date -u "+%G%V")" >> $GITHUB_OUTPUT
-
-    - name: Load package cache (Ubuntu)
-      if: runner.os == 'Linux' && matrix.packages
-      uses: actions/cache@v5
-      with:
-        path: ${{ runner.temp }}/apt-archives/*.deb
-        key: cache-apt-${{ matrix.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}-${{ steps.get-ubuntu-cache-key.outputs.pkg_sig }}-${{ steps.get-ubuntu-cache-key.outputs.key }}
-        restore-keys: |
-          cache-apt-${{ matrix.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}-${{ steps.get-ubuntu-cache-key.outputs.pkg_sig }}
-          cache-apt-${{ matrix.cache-key || 'default' }}-${{ runner.arch }}-${{ steps.get-ubuntu-cache-key.outputs.release }}
-
     - name: Restore cached packages (Ubuntu)
       if: runner.os == 'Linux' && matrix.packages
-      run: |
-        sudo mkdir -p /var/cache/apt/archives ${{ runner.temp }}/apt-archives
-        if compgen -G "${{ runner.temp }}/apt-archives/*.deb" > /dev/null; then
-          sudo mv -f ${{ runner.temp }}/apt-archives/*.deb /var/cache/apt/archives/
-        fi
+      id: restore-apt-cache
+      uses: ./.github/actions/restore-apt-cache
+      with:
+        packages: ${{ matrix.packages }}
+        cache-key: ${{ matrix.cache-key }}
 
     - name: Install packages (Ubuntu)
       if: runner.os == 'Linux' && matrix.packages
@@ -345,13 +325,8 @@ jobs:
         sudo apt-get install -y ${{ matrix.packages }}
 
     - name: Update package cache (Ubuntu)
-      if: runner.os == 'Linux' && matrix.packages
-      run: |
-        if compgen -G "/var/cache/apt/archives/*.deb" > /dev/null; then
-          sudo apt autoclean
-          sudo apt autoremove
-          sudo cp -f /var/cache/apt/archives/*.deb ${{ runner.temp }}/apt-archives/
-        fi
+      if: runner.os == 'Linux' && matrix.packages && steps.restore-apt-cache.outputs.cache-hit != 'true'
+      uses: ./.github/actions/update-apt-cache
 
     - name: Install packages (macOS)
       if: runner.os == 'macOS'