commit 5177712c99d7f0dbc243ed77adb02de910bd32de
parent ad6e6f2a9d6895de9f387b2bd9de8a7e7a476d2b
Author: finwo <finwo@pm.me>
Date: Sat, 14 Mar 2026 01:16:11 +0100
Re-instate action.yml
Diffstat:
| A | .github/workflows/release.yml | | | 99 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | Makefile | | | 15 | +++++++++++---- |
| A | action.yml | | | 83 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 193 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
@@ -0,0 +1,99 @@
+name: Release
+
+on:
+ push:
+ tags:
+ - '*'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ include:
+ - os: linux
+ arch: x86_64
+ - os: linux
+ arch: arm64
+ - os: macos
+ arch: arm64
+ - os: windows
+ arch: x86_64
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set artifact name
+ id: artifact
+ run: |
+ ARTIFACT="dep-${{ matrix.os }}-${{ matrix.arch }}"
+ if [ "${{ matrix.os }}" = "windows" ]; then
+ ARTIFACT="${ARTIFACT}.exe"
+ fi
+ echo "name=$ARTIFACT" >> $GITHUB_OUTPUT
+
+ - name: Install dependencies (Linux)
+ if: matrix.os == 'linux'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y clang curl
+
+ - name: Install dependencies (macOS)
+ if: matrix.os == 'macos'
+ run: |
+ brew install clang
+
+ - name: Install dependencies (Windows cross-compile)
+ if: matrix.os == 'windows'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y mingw-w64 clang curl
+
+ - name: Build for Linux
+ if: matrix.os == 'linux'
+ run: make dep
+
+ - name: Build for macOS
+ if: matrix.os == 'macos'
+ run: make dep
+
+ - name: Build for Windows
+ if: matrix.os == 'windows'
+ run: |
+ make dep CC=x86_64-w64-mingw32-clang LDFLAGS=-lwinhttp \
+ EXE_EXT=.exe ARCH_TARGET=elf64-x86-64 ARCH_BIN=i386
+
+ - name: Rename binary
+ run: |
+ if [ "${{ matrix.os }}" = "windows" ]; then
+ mv dep.exe ${{ steps.artifact.outputs.name }}
+ else
+ mv dep ${{ steps.artifact.outputs.name }}
+ fi
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ steps.artifact.outputs.name }}
+ path: ${{ steps.artifact.outputs.name }}
+
+ release:
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+
+ steps:
+ - name: Download all artifacts
+ uses: actions/download-artifact@v4
+ with:
+ path: artifacts
+
+ - name: Create Release
+ uses: softprops/action-gh-release@v2
+ with:
+ files: artifacts/*/*
+ generate_release_notes: true
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/Makefile b/Makefile
@@ -3,6 +3,13 @@ CC?=clang
FIND=$(shell which gfind find | head -1)
OBJCOPY=$(shell which objcopy)
+UNAME_P:=$(shell uname -p)
+UNAME_M:=$(shell uname -m)
+ARCH_TARGET?=$(shell echo $(UNAME_M) | sed -e 's/x86_64/elf64-x86-64/' -e 's/arm64/elf64-littleaarch64/' -e 's/aarch64/elf64-littleaarch64/')
+ARCH_BIN?=$(shell echo $(UNAME_M) | sed -e 's/x86_64/i386/' -e 's/arm64/aarch64/' -e 's/aarch64/aarch64/')
+
+EXE_EXT?=
+
SRC:=
INCLUDES:=
CFLAGS:=
@@ -50,7 +57,7 @@ CFLAGS+=${INCLUDES}
default: dep
license.o: LICENSE.md
- $(OBJCOPY) --input binary --output elf64-x86-64 --binary-architecture i386 $< $@
+ $(OBJCOPY) --input binary --output $(ARCH_TARGET) --binary-architecture $(ARCH_BIN) $< $@
lib/cofyc/argparse:
mkdir -p lib/cofyc/argparse
@@ -86,12 +93,12 @@ lib/tidwall/json.c:
${CC} $< ${CFLAGS} -c -o $@
dep: $(LIBS) $(OBJ)
- ${CC} ${OBJ} ${CFLAGS} ${LDFLAGS} -o $@
- strip --strip-all $@
+ ${CC} ${OBJ} ${CFLAGS} ${LDFLAGS} -o dep${EXE_EXT}
+ strip --strip-all dep${EXE_EXT}
.PHONY: install
install: dep
- install dep ${DESTDIR}/bin
+ install dep${EXE_EXT} ${DESTDIR}/bin
.PHONY: clean
clean:
diff --git a/action.yml b/action.yml
@@ -0,0 +1,83 @@
+name: Setup DEP package manager
+description: Installs the DEP package manager into the runner
+
+runs:
+ using: composite
+ steps:
+ - name: Determine platform artifact name
+ id: platform
+ shell: bash
+ run: |
+ OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
+ ARCH=$(echo "${{ runner.arch }}" | tr '[:upper:]' '[:lower:]')
+
+ ARTIFACT_NAME="dep-${OS}-${ARCH}"
+ if [ "$OS" = "windows" ]; then
+ ARTIFACT_NAME="${ARTIFACT_NAME}.exe"
+ fi
+
+ echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
+
+ - name: Get tag version
+ id: version
+ shell: bash
+ run: |
+ TAG_REF="${{ github.action_ref }}"
+ if [ -z "$TAG_REF" ]; then
+ TAG_REF="${{ github.ref }}"
+ fi
+ TAG=${TAG_REF#refs/tags/}
+ echo "tag=$TAG" >> $GITHUB_OUTPUT
+
+ - name: Download prebuilt binary
+ id: download
+ shell: bash
+ run: |
+ TAG="${{ steps.version.outputs.tag }}"
+ ARTIFACT="${{ steps.platform.outputs.artifact_name }}"
+
+ mkdir -p "${GITHUB_ACTION_PATH}/dist"
+
+ RESPONSE=$(curl -sL "https://api.github.com/repos/${{ github.action_repository }}/releases/tags/$TAG")
+ DOWNLOAD_URL=$(echo "$RESPONSE" | grep -o '"browser_download_url": *"[^"]*'"$ARTIFACT"'[^"]*"' | sed 's/.*"browser_download_url": *"\([^"]*\)".*/\1/')
+
+ if [ -n "$DOWNLOAD_URL" ]; then
+ echo "Downloading $ARTIFACT from release $TAG"
+ curl -sL "$DOWNLOAD_URL" -o "${GITHUB_ACTION_PATH}/dist/dep"
+ if [ "$ARTIFACT" = "dep-windows-x86_64.exe" ]; then
+ mv "${GITHUB_ACTION_PATH}/dist/dep" "${GITHUB_ACTION_PATH}/dist/dep.exe"
+ fi
+ echo "status=success" >> $GITHUB_OUTPUT
+ else
+ echo "Prebuilt binary not found for $ARTIFACT in release $TAG, will build from source"
+ echo "status=fallback" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Build from source (fallback)
+ if: steps.download.outputs.status == 'fallback'
+ shell: bash
+ run: |
+ echo "Building dep from source..."
+
+ if [ "${{ runner.os }}" = "Windows" ]; then
+ echo "Windows source build not yet implemented, please use a released tag"
+ exit 1
+ fi
+
+ cd "$GITHUB_ACTION_PATH"
+ make clean || true
+ make dep
+
+ mkdir -p "${GITHUB_ACTION_PATH}/dist"
+ mv dep "${GITHUB_ACTION_PATH}/dist/dep"
+
+ - name: Make executable
+ shell: bash
+ run: |
+ if [ "${{ runner.os }}" != "Windows" ]; then
+ chmod +x "${GITHUB_ACTION_PATH}/dist/dep"
+ fi
+
+ - name: Extend executable path
+ shell: bash
+ run: echo "${GITHUB_ACTION_PATH}/dist" >> $GITHUB_PATH