Skip to content

Build and Release AppBundles - (docker, same as toolpacks' infra) #66

Build and Release AppBundles - (docker, same as toolpacks' infra)

Build and Release AppBundles - (docker, same as toolpacks' infra) #66

Workflow file for this run

name: Build and Release AppBundles - (docker, same as toolpacks' infra)
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 AppBundles
runs-on: ubuntu-latest
permissions: write-all
container:
image: "docker.io/azathothas/appbundler-alpine:latest"
options: --privileged
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove stuff
run: |
# These are not compliant nor good. I want to know when my recipes are not compliant.
apk del bash findutils gawk grep diffutils coreutils
- name: Replace the broken lib4bin with one that works
run: |
GOBIN="$GITHUB_WORKSPACE/.local/bin"
mkdir -p "$GOBIN"
echo "PATH=$GOBIN:$PATH" >> $GITHUB_ENV
git clone --depth 1 --branch dev https://github.com/xplshn/pelf
cp ./pelf/* "$GOBIN" || true
cd ./pelf/cmd/dynexec/lib4bin
go install .
- 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: |
ls "$GITHUB_WORKSPACE/baseSystems"
set -x
export PATH="$GITHUB_WORKSPACE/baseSystems:$PATH"
echo "PATH=$PATH" >> $GITHUB_ENV
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 "Listing files of $OUT_DIR"
ls "$OUT_DIR"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: app-bundles
path: ${{ env.OUT_DIR }}/*.AppBundle
release:
name: Release AppBundles
runs-on: ubuntu-latest
needs: build
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: app-bundles
path: ${{ github.workspace }}
- name: Upload individual artifacts
if: ${{ github.event.inputs.release != 'true' }}
run: |
for file in ${{ github.workspace }}/*.AppBundle; do
echo "Uploading $file"
echo "::set-output name=artifact_name::$(basename $file)"
echo "::set-output name=artifact_path::$file"
done
id: upload_individual
- name: Upload individual artifacts
if: ${{ github.event.inputs.release != 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.upload_individual.outputs.artifact_name }}
path: ${{ steps.upload_individual.outputs.artifact_path }}
- name: Upload all artifacts
if: ${{ github.event.inputs.release != 'true' }}
uses: actions/upload-artifact@v4
with:
name: all-app-bundles
path: ${{ github.workspace }}/*.AppBundle
- name: Manage Tags
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
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: Determine if pre-release
id: determine_prerelease
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "prerelease=true" >> $GITHUB_ENV
else
echo "prerelease=false" >> $GITHUB_ENV
fi
- name: Create Release
if: ${{ github.event.inputs.release == 'true' }}
uses: softprops/[email protected]
with:
name: "Weekly Release - ${{ env.TAG_NAME }}"
tag_name: "${{ env.TAG_NAME }}"
prerelease: ${{ env.prerelease }}
draft: false
generate_release_notes: false
make_latest: true
files: |
${{ github.workspace }}/*.AppBundle
continue-on-error: true