Skip to content

Merge pull request #12 from nqminds/feat/add-wifi-con-scripts #34

Merge pull request #12 from nqminds/feat/add-wifi-con-scripts

Merge pull request #12 from nqminds/feat/add-wifi-con-scripts #34

name: Build and Package Demo Server
on:
release:
types: [created, released]
push:
tags:
- 'v0.0.1'
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-arm64:
name: Build ARM64 Server
runs-on: ubuntu-latest
container:
image: ionutnqm/arm64-libs:latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Debug Current Path and List Files
run: |
echo "Current directory:"
pwd
echo "List of files:"
ls -l
- name: Build ARM64 Server
run: aarch64-linux-gnu-gcc -o server_arm64 debian-brski/brski-demo-app-deb/opt/demo-server/server.c -L/libmicrohttpd/src/microhttpd/.libs -L/zlib -lmicrohttpd -lz -static
- name: Set execute permission on ARM64 Server Binary
run: chmod +x server_arm64
- name: Upload server binary as an artifact
uses: actions/upload-artifact@v2
with:
name: server-arm64-binary
path: server_arm64
build-x86_64:
name: Build x86_64 Server
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update package lists
run: sudo apt-get update
- name: Install libmicrohttpd
run: sudo apt-get install -y libmicrohttpd-dev
- name: Create Directory for x86_64 Binary
run: mkdir -p brski-demo-app-deb/opt/demo-server/
- name: Build x86_64 Server
run: gcc -o server_x86_64 debian-brski/brski-demo-app-deb/opt/demo-server/server.c -lmicrohttpd
- name: List files after build
run: |
echo "Current directory for x86_64:"
pwd
echo "List of files:"
ls -l
- name: Rename x86_64 binary for packaging
run: mv server_x86_64 brski-demo-app-deb/opt/demo-server/server_x86_64
- name: Set execute permission on x86_64 Server Binary
run: chmod +x brski-demo-app-deb/opt/demo-server/server_x86_64
- name: Upload x86_64 server binary as an artifact
uses: actions/upload-artifact@v2
with:
name: server-x86_64-binary
path: brski-demo-app-deb/opt/demo-server/server_x86_64
package-deb:
name: Package Debian
runs-on: ubuntu-latest
needs: [build-arm64, build-x86_64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download ARM64 server binary
uses: actions/download-artifact@v2
with:
name: server-arm64-binary
path: debian-brski/brski-demo-app-deb/opt/demo-server/
- name: Build ARM64 Debian Package
run: dpkg-deb --build debian-brski/brski-demo-app-deb brski-demo-app-deb_arm64.deb
- name: Remove ARM64 binary
run: rm debian-brski/brski-demo-app-deb/opt/demo-server/server_arm64
- name: Download x86_64 server binary
uses: actions/download-artifact@v2
with:
name: server-x86_64-binary
path: debian-brski/brski-demo-app-deb/opt/demo-server/
- name: Build x86_64 Debian Package
run: dpkg-deb --build debian-brski/brski-demo-app-deb brski-demo-app-deb-x86_64.deb
- name: Upload ARM64 .deb Package to Artifacts
uses: actions/upload-artifact@v2
with:
name: brski-demo-app-deb-arm64
path: brski-demo-app-deb_arm64.deb
- name: Upload x86_64 .deb Package to Artifacts
uses: actions/upload-artifact@v2
with:
name: brski-demo-app-deb-x86_64
path: brski-demo-app-deb-x86_64.deb
# changed to only update the assets of current release instead of creating a new release
release-debs:
name: Update Release Assets for Debian Packages
runs-on: ubuntu-latest
needs: [build-arm64, build-x86_64, package-deb]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up release information
run: |
echo "RELEASE_TAG=v0.0.1" >> $GITHUB_ENV
echo "RELEASE_NAME=Brski-demo-app v0.0.1" >> $GITHUB_ENV
- name: Check if Release Exists
id: check_release
run: |
RELEASE_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.RELEASE_TAG }}")
RELEASE_ID=$(echo "$RELEASE_DATA" | jq -r '.id')
UPLOAD_URL=$(echo "$RELEASE_DATA" | jq -r '.upload_url')
if [[ "$RELEASE_ID" != "null" ]]; then
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV
echo "exists=true" >> $GITHUB_ENV
else
echo "exists=false" >> $GITHUB_ENV
fi
echo "RELEASE_ID: $RELEASE_ID"
echo "UPLOAD_URL (masked): ${UPLOAD_URL/\{?name,label\}/}"
- name: Download ARM64 Debian Package
if: env.exists == 'true'
uses: actions/download-artifact@v2
with:
name: brski-demo-app-deb-arm64
path: .
- name: Download AMD64 Debian Package
if: env.exists == 'true'
uses: actions/download-artifact@v2
with:
name: brski-demo-app-deb-x86_64
path: .
- name: List files in current directory
run: ls -lah
- name: Upload ARM64 Debian Package to Release
if: env.exists == 'true'
run: |
echo "Uploading ARM64 Debian Package..."
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/}?name=brski-demo-app-deb_arm64.deb"
echo "URL: $UPLOAD_URL"
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: multipart/form-data" \
-F "label=ARM64 Debian Package" \
-F "data=@./brski-demo-app-deb_arm64.deb" \
"$UPLOAD_URL" -v
- name: Upload AMD64 Debian Package to Release
if: env.exists == 'true'
run: |
echo "Uploading AMD64 Debian Package..."
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/}?name=brski-demo-app-deb-x86_64.deb"
echo "URL: ${UPLOAD_URL}"
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: multipart/form-data" \
-F "label=AMD64 Debian Package" \
-F "data=@./brski-demo-app-deb-x86_64.deb" \
"${UPLOAD_URL}" -v