Skip to content

Build and Release AppBundles (Parallel) #2

Build and Release AppBundles (Parallel)

Build and Release AppBundles (Parallel) #2

Workflow file for this run

name: Build and Release AppBundles (Parallel)
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
build:
name: Build and Release AppBundles (Parallel)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
# Find and run all build scripts inside ./programs/*
- name: Run build scripts for all architectures
id: build_step
run: |
# Set output directory
OUT_DIR="$HOME/out"
mkdir -p "$OUT_DIR"
cd ${{ github.workspace }}
DBIN_PGRS="dwarfs-tools bwrap-patched sharun yq jq"
export GOBIN="$HOME/.local/bin"
mkdir -p "$GOBIN"
git clone --depth 1 --branch dev https://github.com/xplshn/pelf
cp ./pelf/pelf* "$GOBIN"
cp ./pelf/cmd/misc/* "$GOBIN"
cd pelf/cmd/pelfd
go build -o "$GOBIN/pelfd"
cd ../dynexec/lib4bin
go build -o "$GOBIN/lib4bin"
wget -qO- "https://raw.githubusercontent.com/xplshn/dbin/master/stubdl" | sh -s -- --install "$GOBIN/dbin" add $DBIN_PGRS && \
export PATH="$GOBIN:$PATH" && {
ln -sfT "$GOBIN/dwarfs-tools" "$GOBIN/mkdwarfs"
ln -sfT "$GOBIN/dwarfs-tools" "$GOBIN/dwarfs"
ln -sfT "$GOBIN/bwrap-patched" "$GOBIN/bwrap"
}
cd ${{ github.workspace }}
ROOTFS_URL="$(curl -qsL https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/latest-releases.yaml | yq '.[0].file')"
ROOTFS_URL="https://dl-cdn.alpinelinux.org/alpine/edge/releases/$(uname -m)/${ROOTFS_URL}"
export ROOTFS_URL
pelfCreator -m xplshn -n devEnv -p "fuse3 build-base go git" -z -c
devEnv="$(echo ${{ github.workspace }}/devEnv*/AppRun)"
cd "$OUT_DIR"
# Check if the recipes directory exists
if [ -d "${{ github.workspace }}/recipes" ]; then
echo "Listing contents of ./recipes:"
ls -l "${{ github.workspace }}/recipes/"
# Iterate over build scripts in recipes/*
find "${{ github.workspace }}/recipes" -type f -name "*.sh" -print0 | \
xargs -0 -n 1 -P "$(nproc)" -I {} sh -c '
echo "Running {}..."
"${devEnv}" "{}"
'
else
echo "No recipes directory found, skipping."
fi
# Append architecture to the filenames
ARCH=$(uname -m)
for f in $OUT_DIR/*.AppBundle; do
mv "$f" "${f%.AppBundle}-${ARCH}.dwfs.AppBundle"
done
ls "$OUT_DIR"
# Set the output for the OUT_DIR variable
echo "OUT_DIR=${OUT_DIR}" >> $GITHUB_ENV
continue-on-error: true
# Remove older tags if more than 5 exist
- name: Manage Tags
run: |
# Fetch all tags
git fetch --tags
# Get the list of tags and count them
TAGS=$(git tag | sort -V) # Sort tags in version order
TAG_COUNT=$(echo "$TAGS" | wc -l)
if [ "$TAG_COUNT" -gt 5 ]; then
# Get the tags to delete (all except the latest)
TAGS_TO_DELETE=$(echo "$TAGS" | head -n -1) # All but the last tag
# Delete each old tag
for TAG in $TAGS_TO_DELETE; do
echo "Deleting tag: $TAG"
git tag -d "$TAG" || echo "Tag $TAG could not be deleted locally."
git push origin --delete "$TAG" || echo "Tag $TAG could not be deleted from remote."
done
else
echo "Tag count is $TAG_COUNT, no tags to delete."
fi
# Create GitHub Release
- name: Create Release
uses: marvinpinto/action-automatic-releases@latest
with:
title: "Weekly Release - Run ${{ github.run_id }}"
automatic_release_tag: weekly-release-${{ github.run_id }}
prerelease: false
draft: false
files: |
${{ env.OUT_DIR }}/*.dwfs.AppBundle
repo_token: ${{ secrets.GITHUB_TOKEN }}