3434 default : true
3535
3636permissions :
37- contents : write
37+ contents : read
38+
39+ concurrency :
40+ group : void-xbps-${{ github.ref }}
41+ cancel-in-progress : false
3842
3943jobs :
44+ preflight :
45+ name : Check for unpublished changes
46+ runs-on : ubuntu-latest
47+ outputs :
48+ should_build : ${{ steps.check.outputs.should_build }}
49+ steps :
50+ - name : Check published commit
51+ id : check
52+ env :
53+ MANIFEST_URL : https://void.danklinux.com/dms/current/manifest.json
54+ run : |
55+ SHOULD_BUILD=true
56+ if [ "${{ github.event_name }}" = "schedule" ]; then
57+ PUBLISHED_COMMIT="$(curl -fsSL --retry 3 "$MANIFEST_URL" | jq -r '.source_commit // empty' 2>/dev/null || true)"
58+ if [ "$PUBLISHED_COMMIT" = "${{ github.sha }}" ]; then
59+ SHOULD_BUILD=false
60+ echo "${{ github.sha }} is already published; skipping the scheduled build."
61+ fi
62+ fi
63+ echo "should_build=$SHOULD_BUILD" >> "$GITHUB_OUTPUT"
64+
4065 build-and-deploy :
4166 name : Build & Deploy XBPS packages
4267 runs-on : ubuntu-latest
43- if : github.repository == 'AvengeMedia/DankMaterialShell'
68+ needs : preflight
69+ if : github.repository == 'AvengeMedia/DankMaterialShell' && needs.preflight.outputs.should_build == 'true'
70+ env :
71+ AWS_ACCESS_KEY_ID : ${{ secrets.R2_ACCESS_KEY_ID }}
72+ AWS_SECRET_ACCESS_KEY : ${{ secrets.R2_SECRET_ACCESS_KEY }}
73+ AWS_DEFAULT_REGION : auto
74+ AWS_EC2_METADATA_DISABLED : true
75+ R2_BUCKET : danklinux-void
76+ R2_ENDPOINT : https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
77+ R2_PREFIX : dms
78+ REPOSITORY_DIR : ${{ github.workspace }}/r2-repo
79+ SOURCE_COMMIT : ${{ github.sha }}
4480 steps :
4581 - name : Checkout repository
4682 uses : actions/checkout@v6
4783 with :
4884 ref : ${{ github.event.release.tag_name || (github.event.inputs.version && (startsWith(github.event.inputs.version, 'v') && github.event.inputs.version || format('v{0}', github.event.inputs.version))) || github.ref }}
4985 fetch-depth : 0
5086
51- - name : Checkout gh-pages branch
87+ - name : Record checked-out source commit
88+ run : echo "SOURCE_COMMIT=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
89+
90+ - name : Download current R2 repository
5291 run : |
53- git clone --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages-repo || {
54- echo "⚠️ gh-pages branch not found or empty, initializing a new one..."
55- mkdir gh-pages-repo
56- cd gh-pages-repo
57- git init
58- git checkout -b gh-pages
59- git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
60- cd ..
61- }
92+ aws --version
93+ bash .github/scripts/publish-void-r2.sh download
6294
6395 - name : Install XBPS Static Utilities
6496 run : |
@@ -132,19 +164,19 @@ jobs:
132164 - name : Configure repositories
133165 run : |
134166 # Append the repository to repos-remote templates so xbps-src translates it automatically
135- echo "repository=https://avengemedia.github.io/DankLinux /current" >> void-packages/etc/xbps.d/repos-remote.conf
136- echo "repository=https://avengemedia.github.io/DankLinux /current" >> void-packages/etc/xbps.d/repos-remote-x86_64-multilib.conf
167+ echo "repository=https://void.danklinux.com/danklinux /current" >> void-packages/etc/xbps.d/repos-remote.conf
168+ echo "repository=https://void.danklinux.com/danklinux /current" >> void-packages/etc/xbps.d/repos-remote-x86_64-multilib.conf
137169
138170 # Add any existing compiled packages to the build cache directory to avoid rebuilds
139- if [ -d "gh-pages -repo/current" ]; then
171+ if [ -d "r2 -repo/current" ]; then
140172 mkdir -p void-packages/hostdir/binpkgs
141- cp -L gh-pages -repo/current/*.xbps void-packages/hostdir/binpkgs/ 2>/dev/null || true
173+ cp -L r2 -repo/current/*.xbps void-packages/hostdir/binpkgs/ 2>/dev/null || true
142174 xbps-rindex -a void-packages/hostdir/binpkgs/*.xbps 2>/dev/null || true
143175 fi
144176
145177 - name : Build packages
146178 run : |
147- mkdir -p gh-pages -repo/current
179+ mkdir -p r2 -repo/current
148180
149181 BUILD_DMS="${{ github.event.inputs.build_dms || 'true' }}"
150182 BUILD_GREETER="${{ github.event.inputs.build_greeter || 'true' }}"
@@ -216,7 +248,7 @@ jobs:
216248 mkdir -p "$SRC_CACHE"
217249 tar -czf "${SRC_CACHE}/dms-git-${GIT_VER}.tar.gz" \
218250 --exclude=void-packages \
219- --exclude=gh-pages -repo \
251+ --exclude=r2 -repo \
220252 --exclude=.git \
221253 --exclude=danklinux \
222254 -C .. .
@@ -230,13 +262,13 @@ jobs:
230262
231263 EXPECTED_GIT_FILE="dms-git-${GIT_VER}_1.x86_64.xbps"
232264
233- if [ -f "../gh-pages -repo/current/$EXPECTED_GIT_FILE" ] && [ "$FORCE_REBUILD" != "true" ]; then
265+ if [ -f "../r2 -repo/current/$EXPECTED_GIT_FILE" ] && [ "$FORCE_REBUILD" != "true" ]; then
234266 echo "✅ $EXPECTED_GIT_FILE already exists, skipping build."
235267 else
236268 echo "🔨 Compiling dms-git..."
237269 ./xbps-src pkg dms-git
238- rm -f "../gh-pages -repo/current/${EXPECTED_GIT_FILE}"
239- cp -L hostdir/binpkgs/dms-git-*.xbps ../gh-pages -repo/current/
270+ rm -f "../r2 -repo/current/${EXPECTED_GIT_FILE}"
271+ cp -L " hostdir/binpkgs/${EXPECTED_GIT_FILE}" ../r2 -repo/current/
240272 fi
241273 fi
242274
@@ -246,13 +278,13 @@ jobs:
246278 STABLE_REV=$(grep -E '^revision=' srcpkgs/dms/template | cut -d= -f2 | tr -d '"')
247279
248280 EXPECTED_DMS_FILE="dms-${STABLE_VER}_${STABLE_REV}.x86_64.xbps"
249- if [ -f "../gh-pages -repo/current/$EXPECTED_DMS_FILE" ] && [ "$FORCE_REBUILD" != "true" ]; then
281+ if [ -f "../r2 -repo/current/$EXPECTED_DMS_FILE" ] && [ "$FORCE_REBUILD" != "true" ]; then
250282 echo "✅ $EXPECTED_DMS_FILE already exists, skipping build."
251283 else
252284 echo "🔨 Compiling dms ($STABLE_VER)..."
253285 ./xbps-src pkg dms
254- rm -f "../gh-pages -repo/current/${EXPECTED_DMS_FILE}"
255- cp -L hostdir/binpkgs/dms-${STABLE_VER}_${STABLE_REV}.x86_64.xbps ../gh-pages -repo/current/
286+ rm -f "../r2 -repo/current/${EXPECTED_DMS_FILE}"
287+ cp -L hostdir/binpkgs/dms-${STABLE_VER}_${STABLE_REV}.x86_64.xbps ../r2 -repo/current/
256288 fi
257289 fi
258290
@@ -262,22 +294,21 @@ jobs:
262294 GREETER_REV=$(grep -E '^revision=' srcpkgs/dms-greeter/template | cut -d= -f2 | tr -d '"')
263295
264296 EXPECTED_GREETER_FILE="dms-greeter-${GREETER_VER}_${GREETER_REV}.x86_64.xbps"
265- if [ -f "../gh-pages -repo/current/$EXPECTED_GREETER_FILE" ] && [ "$FORCE_REBUILD" != "true" ]; then
297+ if [ -f "../r2 -repo/current/$EXPECTED_GREETER_FILE" ] && [ "$FORCE_REBUILD" != "true" ]; then
266298 echo "✅ $EXPECTED_GREETER_FILE already exists, skipping build."
267299 else
268300 echo "🔨 Compiling dms-greeter ($GREETER_VER)..."
269301 ./xbps-src pkg dms-greeter
270- rm -f "../gh-pages -repo/current/${EXPECTED_GREETER_FILE}"
271- cp -L hostdir/binpkgs/dms-greeter-${GREETER_VER}_${GREETER_REV}.x86_64.xbps ../gh-pages -repo/current/
302+ rm -f "../r2 -repo/current/${EXPECTED_GREETER_FILE}"
303+ cp -L hostdir/binpkgs/dms-greeter-${GREETER_VER}_${GREETER_REV}.x86_64.xbps ../r2 -repo/current/
272304 fi
273305 fi
274306
275307 - name : Index and sign repository
276308 run : |
277- cd gh-pages -repo/current
309+ cd r2 -repo/current
278310
279- # Clean up any stale or dangling signature files to prevent O_CREAT ENOENT errors
280- rm -f *.sig2 *.sig
311+ rm -f *.sig
281312
282313 # Guard: nothing to index if no .xbps files exist
283314 if ! ls *.xbps 1>/dev/null 2>&1; then
@@ -287,6 +318,14 @@ jobs:
287318
288319 # Regenerate repo index
289320 xbps-rindex -a $(pwd)/*.xbps
321+ xbps-rindex --remove-obsoletes $(pwd)
322+
323+ # Remove signatures left behind by obsolete packages. Signatures for
324+ # unchanged immutable packages are retained byte-for-byte.
325+ for sig in *.sig2; do
326+ [ -e "$sig" ] || break
327+ [ -f "${sig%.sig2}" ] || rm -f "$sig"
328+ done
290329
291330 # Sign repository
292331 echo "${{ secrets.XBPS_PRIVATE_KEY }}" > /tmp/xbps_privkey.pem
@@ -297,10 +336,5 @@ jobs:
297336
298337 rm -f /tmp/xbps_privkey.pem
299338
300- - name : Deploy to gh-pages branch
301- run : |
302- cd gh-pages-repo
303- git config user.name "github-actions[bot]"
304- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
305- git add current/
306- git diff --quiet && git diff --staged --quiet || (git commit -m "Update XBPS packages [skip ci]" && git push origin gh-pages)
339+ - name : Publish repository to R2
340+ run : bash .github/scripts/publish-void-r2.sh publish
0 commit comments