From 609ef1055cfae783b48cf26ced3a128c0b3b127d Mon Sep 17 00:00:00 2001 From: Andrew Fasano Date: Fri, 15 Dec 2023 14:52:13 -0500 Subject: [PATCH] Build and release libraries in CI --- .github/workflows/build.yaml | 52 ++++++++++++++++++++++++++++++++++++ .gitignore | 1 + package.sh | 25 +++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .gitignore create mode 100755 package.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..e945508 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,52 @@ +name: Compile and publish libnvram + +on: + push: + branches: + - master + +jobs: + build: + runs-on: panda-arc + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build + run: | + docker run --rm -v $PWD:/app -w /app ghcr.io/panda-re/embedded-toolchains_rust:latest /app/package.sh + + - name: Save package + uses: actions/upload-artifact@v3 + with: + name: libnvram-latest.tar.gz + path: libnvram-latest.tar.gz + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: release_${{ github.sha }} + release_name: Release ${{ github.ref }} + body: | + Release @${{ github.ref }} + draft: true + prerelease: false + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./libnvram-latest.tar.gz + asset_name: libnvram-latest.tar.gz + asset_content_type: application/gzip + - name: Publish release + uses: StuYarrow/publish-release@v1.1.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + id: ${{ steps.create_release.outputs.id }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c259b11 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +libnvram.tar.gz diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..fa6eab4 --- /dev/null +++ b/package.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -eux + +# Host is mapped at /app + +rm -rf /app/out +mkdir /app/out + +SCRATCH=$(mktemp -d)/libnvram +mkdir $SCRATCH + +CC=arm-linux-musleabi-gcc make libnvram.so -C /app +mv libnvram.so $SCRATCH/libnvram.so.arm +make clean + +CC=mipsel-linux-musl-gcc make libnvram.so -C /app +mv libnvram.so $SCRATCH/libnvram.so.mipsel +make clean + +CC=mipseb-linux-musl-gcc make libnvram.so -C /app +mv libnvram.so $SCRATCH/libnvram.so.mipseb +make clean + +tar -czvf /app/libnvram.tar.gz -C $(dirname $SCRATCH) libnvram +rm -rf /app/out \ No newline at end of file