diff --git a/.github/workflows/publish-catalog.yml b/.github/workflows/publish-catalog.yml new file mode 100644 index 0000000..e431a16 --- /dev/null +++ b/.github/workflows/publish-catalog.yml @@ -0,0 +1,49 @@ +name: Publish Catalog Makefiles + +on: + push: + branches: [main] + paths: + - 'catalog/**/*.mk' + +permissions: + packages: write + contents: read + +jobs: + publish-catalog: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + + - name: Install Remake CLI + run: | + curl -fsSL https://raw.githubusercontent.com/TrianaLab/remake/main/scripts/get-remake.sh | bash + + - name: Login to GitHub Container Registry + run: | + remake login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} + + - name: Determine release tag + id: tag + run: | + git fetch --tags + echo "::set-output name=VERSION::$(git describe --tags --abbrev=0)" + + - name: Publish Makefiles as OCI artifacts + run: | + for filepath in catalog/**/*.mk; do + NAME=$(basename "$filepath" .mk) + + # Extract version defined in the Makefile (requires each .mk to define VERSION := x.y.z) + VERSION=$(grep -E '^VERSION[[:space:]]*:?=' "$filepath" | head -n1 | sed 's/.*[:=]\s*//') + + if [ -z "$VERSION" ]; then + echo "[warning] No VERSION found in $filepath, skipping" + continue + fi + + echo "Publishing $filepath as tags: $VERSION, latest" + remake push -f "$filepath" ghcr.io/TrianaLab/$NAME:$VERSION + remake push -f "$filepath" ghcr.io/TrianaLab/$NAME:latest + done diff --git a/.gitignore b/.gitignore index cb3d21d..43e932d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,4 @@ go.work.sum .env # VSCode -.vscode/ - -# Makefiles -*.mk \ No newline at end of file +.vscode/ \ No newline at end of file diff --git a/catalog/runtimes/make-os.mk b/catalog/runtimes/make-os.mk new file mode 100644 index 0000000..2271e63 --- /dev/null +++ b/catalog/runtimes/make-os.mk @@ -0,0 +1,36 @@ +# make-os.mk — Detect host OS, distribution, version, and architecture +# Supports: Linux (any distro), macOS, Windows (via PowerShell) + +VERSION := 0.1.0 + +.PHONY: detect + +detect: +ifeq ($(OS),Windows_NT) + @powershell -NoProfile -Command "\ + $ver = (Get-CimInstance Win32_OperatingSystem).Version; \ + $arch = if ($env:PROCESSOR_ARCHITECTURE -match 'ARM') { 'arm64' } else { 'amd64' }; \ + Write-Output \"windows windows $ver $arch\"\ + " +else + @sh -c '\ + UNAME_S="$$(uname -s)"; \ + UNAME_M="$$(uname -m)"; \ + if [ "$$UNAME_S" = "Darwin" ]; then \ + OS_NAME=macos; \ + DISTRO=macos; \ + VERSION="$$(sw_vers -productVersion)"; \ + else \ + OS_NAME=linux; \ + . /etc/os-release; \ + DISTRO="$$ID"; \ + VERSION="$$VERSION_ID"; \ + fi; \ + if echo $$UNAME_M | grep -qE "arm|aarch64"; then \ + ARCH=arm64; \ + else \ + ARCH=amd64; \ + fi; \ + echo "$$OS_NAME $$DISTRO $$VERSION $$ARCH"; \ + ' +endif