diff --git a/.gitea/workflows/release_arm64v8-edge.yml b/.gitea/workflows/release_arm64v8-edge.yml index ec5c394..22d6614 100755 --- a/.gitea/workflows/release_arm64v8-edge.yml +++ b/.gitea/workflows/release_arm64v8-edge.yml @@ -18,9 +18,8 @@ jobs: shell: sh run: | # faster mirror + essential build tools - echo "https://alpine.sakamoto.pl/alpine/$(cat /etc/os-release | grep PRETT | cut -d ' ' -f 3 | cut -d '"' -f 1)/main" > /etc/apk/repositories - echo "https://alpine.sakamoto.pl/alpine/$(cat /etc/os-release | grep PRETT | cut -d ' ' -f 3 | cut -d '"' -f 1)/community" >> /etc/apk/repositories - echo "https://alpine.sakamoto.pl/alpine/$(cat /etc/os-release | grep PRETT | cut -d ' ' -f 3 | cut -d '"' -f 1)/testing" >> /etc/apk/repositories + MIRROR="https://alpine.sakamoto.pl/alpine/$(. /etc/os-release; echo $PRETTY_NAME | cut -d '"' -f2)" + printf "%s/main\n%s/community\n%s/testing\n" "$MIRROR" "$MIRROR" "$MIRROR" > /etc/apk/repositories apk update && apk upgrade apk add bash git curl alpine-sdk abuild sudo shadow fuse sshfs nodejs wget @@ -46,7 +45,7 @@ jobs: su - runner -c 'wget -q https://static.itmodulo.eu/dl/repo/public_keys/alpine/itmodulo%40disroot.org-65b4f779.rsa.pub -P ~/.abuild/' echo "${{ secrets.REPO_PRIVKEY }}" > /home/runner/.abuild/${{ secrets.REPO_PRIVKEY_FILENAME }} && chown runner:runner /home/runner/.abuild/${{ secrets.REPO_PRIVKEY_FILENAME }} su - runner -c "echo 'PACKAGER_PRIVKEY="/home/runner/.abuild/${{ secrets.REPO_PRIVKEY_FILENAME }}"' >> ~/.abuild/abuild.conf" - echo "done" + echo "done"" - name: Checkout sources uses: actions/checkout@v4 @@ -58,34 +57,33 @@ jobs: mkdir -p remote_index curl -sfL "${REPO_URL}/APKINDEX.tar.gz" -o remote_index/APKINDEX.tar.gz tar -xzf remote_index/APKINDEX.tar.gz -C remote_index - # Extract P: and V: fields into a list of "name-version-pkgrel" - awk ' - /^P:/ { pkg=$2 } - /^V:/ { ver=$2 } - /^PR:/ { pr=$2; print pkg "-" ver "-" pr } - ' remote_index/APKINDEX > remote_index/list.txt - echo "::set-output name=existing::$(sort remote_index/list.txt | paste -sd, -)" + awk '/^P:/ { pkg=$2 } + /^V:/ { ver=$2 } + /^PR:/{ pr=$2; print pkg "-" ver "-" pr }' \ + remote_index/APKINDEX > remote_index/list.txt - name: Build only missing packages shell: bash run: | - EXISTING="$(echo "${{ steps.get_remote.outputs.existing }}" | tr ',' '\n')" - echo "$EXISTING" - mkdir -p built newpkgs + EXISTING_LIST=remote_index/list.txt + mkdir -p newpkgs for d in edge/*; do - cd "$d" - # source the APKBUILD so we get PKGNAME, PKGVER, PKGREL - . APKBUILD - ident="${PKGNAME}-${PKGVER}-${PKGREL}" - if echo "$EXISTING" | grep -qx "$ident"; then - echo "Skipping $ident (already in repo)" - else - echo "Building $ident..." - abuild -r -c - # collect the resulting .apk - mv /home/runner/packages/srcpkgs/aarch64/${PKGNAME}-*.apk ../../newpkgs/ || true - fi - cd - >/dev/null + # skip non-directories + [ -d "$d" ] || continue + + # as runner: source APKBUILD, set ident + sudo -u runner bash -c " + cd '$d' + . APKBUILD + echo \"Checking $PKGNAME-$PKGVER-$PKGREL\" + if grep -F -x \"$PKGNAME-$PKGVER-$PKGREL\" ../../${EXISTING_LIST}; then + echo \" → skip, already in repo\" + else + echo \" → building…\" + abuild -r -c + mv /home/runner/packages/srcpkgs/aarch64/${PKGNAME}-*.apk ../../newpkgs/ || true + fi + " done - name: Sync new pkgs, clean old versions, rebuild & sign index @@ -101,19 +99,17 @@ jobs: cd /home/runner/remote - # For each newly-built package, remove older versions - for pkg in /home/runner/newpkgs/*.apk; do - base=$(basename "$pkg" | sed -E 's/(-[0-9]+\.[0-9]+.*)//') + # Remove old iterations of each new pkg + for apk in /home/runner/newpkgs/*.apk; do + base=$(basename "$apk" | sed 's/-[0-9].*//') rm -f ${base}-*.apk || true done - # Copy over the truly new files + # Copy new ones in cp /home/runner/newpkgs/*.apk . - # Rebuild the index + # Rebuild index and sign apk index -o APKINDEX.tar.gz *.apk - - # Sign it abuild-sign APKINDEX.tar.gz fusermount -u /home/runner/remote