generated from archlinux/template
Add up-to-date check to not recompile things that have not changed
This commit is contained in:
parent
cec6417f14
commit
a383314040
47
.gitea/workflows/up-to-date.sh
Executable file
47
.gitea/workflows/up-to-date.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
# Source the PKGBUILD in a subshell to avoid polluting the global environment
|
||||
(
|
||||
source ./PKGBUILD
|
||||
|
||||
# Convert pkgname to array in case it's a single string
|
||||
pkgnames=("${pkgname[@]}")
|
||||
|
||||
for pkg in "${pkgnames[@]}"; do
|
||||
echo "Checking package: $pkg"
|
||||
|
||||
if pacman -Si "$pkg" &>/dev/null; then
|
||||
echo "Package '$pkg' exists in a repository."
|
||||
|
||||
# Get the package build date
|
||||
pkg_build_date=$(date -d "$(pacman -Si "$pkg" | grep 'Build Date' | cut -d: -f2-)" +%s)
|
||||
|
||||
all_deps=("${depends[@]}" "${makedepends[@]}" "${optdepends[@]}")
|
||||
|
||||
# Check each dependency
|
||||
for dep in "${all_deps[@]}"; do
|
||||
dep_name=$(echo "$dep" | sed 's/[<>=].*//') # Remove version constraints
|
||||
echo "Querying dependency: $dep_name"
|
||||
|
||||
if pacman -Si "$dep_name" &>/dev/null; then
|
||||
dep_build_date=$(date -d "$(pacman -Si "$dep_name" | grep 'Build Date' | cut -d: -f2-)" +%s)
|
||||
if (( dep_build_date >= pkg_build_date )); then
|
||||
echo "Dependency '$dep_name' has newer or equal build date than '$pkg'."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Dependency '$dep_name' not found in repositories. Skipping."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All dependencies are older than package '$pkg'."
|
||||
exit 0
|
||||
else
|
||||
echo "Package '$pkg' does NOT exist in any repository."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
)
|
@ -37,12 +37,37 @@ jobs:
|
||||
run: |
|
||||
curl https://idlesleep.wolproxy.seeseepuff.be/status
|
||||
|
||||
check:
|
||||
name: Check if rebuild is necessary
|
||||
runs-on: ubuntu-amd64
|
||||
needs: wake
|
||||
outputs:
|
||||
up-to-date: ${{ steps.up-to-date.outputs.up-to-date }}
|
||||
container:
|
||||
image: gitea.seeseepuff.be/archlinux/archlinux:latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Ensure image is up-to-date
|
||||
run: |
|
||||
sudo pacman -Sy --noconfirm
|
||||
|
||||
- name: Check if rebuild is necessary
|
||||
id: up-to-date
|
||||
run: |
|
||||
set +e
|
||||
.gitea/workflows/up-to-date.sh
|
||||
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
|
||||
set -e
|
||||
|
||||
build:
|
||||
name: Build and Push
|
||||
runs-on: ubuntu-amd64
|
||||
needs: wake
|
||||
needs: check
|
||||
container:
|
||||
image: gitea.seeseepuff.be/archlinux/archlinux:latest
|
||||
if: needs.check.outputs.up-to-date == '1'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
@ -50,6 +75,10 @@ jobs:
|
||||
- name: Ensure image is up-to-date
|
||||
run: |
|
||||
sudo pacman -Syu --noconfirm
|
||||
|
||||
- name: Check if rebuild is necessary
|
||||
run: |
|
||||
.gitea/workflows/up-to-date.sh
|
||||
|
||||
- name: Build package
|
||||
run: |
|
||||
|
3
PKGBUILD
3
PKGBUILD
@ -15,7 +15,8 @@ optdepends=(
|
||||
'sudo: privilege elevation'
|
||||
'doas: privilege elevation'
|
||||
)
|
||||
makedepends=('go>=1.21')
|
||||
makedepends=('go>=1.21'
|
||||
'helloworld')
|
||||
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/Jguer/yay/archive/v${pkgver}.tar.gz")
|
||||
sha256sums=('f3f4af5d84f75abc3ea726f192568bdf570e2632b4b3c214effa4bba406ad293')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user