Update gen3.yml #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release AppBundles - Alpine | |
on: | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
inputs: | |
script_pattern: | |
description: "Pattern to match scripts to build (leave empty to build all)" | |
required: false | |
default: "" | |
release: | |
description: "Create a release (true/false)" | |
required: false | |
default: "true" | |
jobs: | |
build: | |
name: Build and Release AppBundles | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Git operations outside of the container | |
- name: Manage Tags (Outside Container) | |
if: ${{ github.event.inputs.release == 'true' }} | |
run: | | |
git fetch --tags | |
TAGS=$(git tag | sort -V) | |
TAG_COUNT=$(echo "$TAGS" | wc -l) | |
if [ "$TAG_COUNT" -gt 5 ]; then | |
TAGS_TO_DELETE=$(echo "$TAGS" | head -n -1) | |
for TAG in $TAGS_TO_DELETE; do | |
echo "Deleting tag: $TAG" | |
git tag -d "$TAG" | |
git push origin --delete "$TAG" | |
done | |
else | |
echo "Tag count is $TAG_COUNT, no tags to delete." | |
fi | |
- name: Create Git Tag (Outside Container) | |
if: ${{ github.event.inputs.release == 'true' }} | |
run: | | |
TAG_NAME="v$(date +'%Y%m%d%H%M%S')" | |
echo "Creating tag: $TAG_NAME" | |
git tag "$TAG_NAME" | |
git push origin "$TAG_NAME" | |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
- name: Set up container environment | |
container: | |
image: alpine:edge | |
options: --privileged | |
- name: Install dependencies in container | |
run: | | |
apk update | |
apk add --no-cache fuse3 fuse build-base libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev linux-headers mesa-dev go git bash tree | |
- name: Prepare environment | |
run: | | |
GOBIN="$GITHUB_WORKSPACE/.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" | |
echo "GOBIN=$GOBIN" >> $GITHUB_ENV | |
echo "PATH=$GOBIN:$PATH" >> $GITHUB_ENV | |
- name: Build lib4bin | |
run: | | |
cd pelf/cmd/dynexec/lib4bin | |
go build -o "$GOBIN/lib4bin" | |
- name: Install tools | |
run: | | |
DBIN_PGRS="dwarfs-tools bwrap-patched sharun yq jq eget2" | |
wget -qO- "https://raw.githubusercontent.com/xplshn/dbin/master/stubdl" | DBIN_INSTALL_DIR="$GOBIN" sh -s -- --install "$GOBIN/dbin" add $DBIN_PGRS | |
ln -sfT "$GOBIN/dwarfs-tools" "$GOBIN/mkdwarfs" | |
ln -sfT "$GOBIN/dwarfs-tools" "$GOBIN/dwarfs" | |
ln -sfT "$GOBIN/bwrap-patched" "$GOBIN/bwrap" | |
- name: Set OUT_DIR environment variable | |
run: | | |
OUT_DIR="$GITHUB_WORKSPACE/APPBUNDLES" | |
mkdir -p "$OUT_DIR" | |
echo "OUT_DIR=${OUT_DIR}" >> $GITHUB_ENV | |
- name: List available scripts | |
run: | | |
echo "Listing available recipes:" | |
tree "$GITHUB_WORKSPACE/recipes" | |
- name: Run selected build scripts in OUT_DIR | |
run: | | |
GOBIN="$GITHUB_WORKSPACE/.local/bin" | |
export PATH="$GOBIN:$PATH" | |
cd $OUT_DIR | |
SCRIPT_PATTERN="${{ github.event.inputs.script_pattern }}" | |
if [ -z "$SCRIPT_PATTERN" ]; then | |
echo "No script pattern provided, running all scripts." | |
PATTERN=".*" | |
else | |
echo "Pattern provided: $SCRIPT_PATTERN" | |
PATTERN="$SCRIPT_PATTERN" | |
fi | |
for script in "$GITHUB_WORKSPACE/recipes/"*/*.*sh; do | |
if echo "$script" | grep -E "$PATTERN"; then | |
echo "Running $script" | |
chmod +x "$script" | |
DEBUG=1 "$script" | |
else | |
echo "Skipping $script (does not match pattern)" | |
fi | |
done | |
- name: List output | |
run: | | |
echo "Archiving output from $OUT_DIR" | |
ls "$OUT_DIR" | |
- name: Upload build artifacts | |
if: ${{ github.event.inputs.release == 'false' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-bundles | |
path: ${{ env.OUT_DIR }}/*.AppBundle | |
- name: Create Release | |
if: ${{ github.event.inputs.release == 'true' }} | |
uses: softprops/action-gh-release@v2.0.8 | |
with: | |
name: "Weekly Release - ${{ env.TAG_NAME }}" | |
tag_name: "${{ env.TAG_NAME }}" | |
prerelease: false | |
draft: false | |
generate_release_notes: false | |
make_latest: true | |
files: | | |
${{ env.OUT_DIR }}/*.AppBundle | |
continue-on-error: true |