Skip to content

Build and Release AppBundles #54

Build and Release AppBundles

Build and Release AppBundles #54

Workflow file for this run

name: Build and Release AppBundles
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
build:
name: Build and Release AppBundles
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/*
for dir in "${{ github.workspace }}/recipes/"*; do
if [ -d "$dir" ]; then
for script in "$dir"/*.*sh; do # Target files ending in .sh
# Check if the script exists before making it executable
if [ -e "$script" ]; then
echo "Making $script executable..."
chmod +x "$script"
echo "Running $script..."
"${devEnv}" "$script"
else
echo "$script does not exist, skipping."
fi
done
else
echo "$dir is not a directory, skipping."
fi
done
else
echo "No recipes directory found, skipping."
fi
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 }}/*.AppBundle
repo_token: ${{ secrets.GITHUB_TOKEN }}