Skip to content

Commit

Permalink
Bug fixes for build script and build action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
WombatFromHell committed Jun 4, 2024
1 parent 1bde86d commit 82d6559
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
CI: "true"

steps:
- uses: actions/checkout@v4
Expand All @@ -21,10 +23,11 @@ jobs:
- name: Build project
run: |
chmod +x ./build.sh
export CI=${{ env.CI }}
./build.sh
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: veridian-controller_${{ steps.get_version.outputs.VERSION }}.AppImage
path: target/appimage/*.AppImage
name: veridian-controller_${{ steps.get_version.outputs.VERSION }}
path: target/appimage/*.*
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ RUN wget https://github.com/AppImage/AppImageKit/releases/download/continuous/ap
WORKDIR /app
COPY . /app/

ARG CI
ENV CI=$CI

ENTRYPOINT [ "/app/entrypoint.sh" ]
16 changes: 2 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#!/usr/bin/env bash

CI="${CI:-false}"
IMAGE_NAME="veridian"

ARTIFACT_PATH="./target/appimage"
ARTIFACT="veridian-controller"
ARTIFACT_EXT=".AppImage"

get_version() {
VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "//' | sed 's/"//')
}

selinux_status() {
ENFORCING=false
if command -v getenforce; then
Expand All @@ -31,12 +24,7 @@ fi
rm -rf ./target/appimage &&
mkdir -p ./target

docker build -t $IMAGE_NAME .
docker build --build-arg CI="$CI" -t $IMAGE_NAME .
docker run --rm \
-v "./target:/app/target${RELABEL}" \
--name $IMAGE_NAME $IMAGE_NAME
# rename the release artifact with the current version from Cargo.toml
mv -f \
"${ARTIFACT_PATH}/${ARTIFACT}${ARTIFACT_EXT}" \
"${ARTIFACT_PATH}/${ARTIFACT}_${VERSION}${ARTIFACT_EXT}"
echo "" && echo "AppImage release build created at: \"${ARTIFACT_PATH}/${ARTIFACT}_${VERSION}${ARTIFACT_EXT}\""
24 changes: 24 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
#!/usr/bin/env bash

get_version() {
VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "//' | sed 's/"//')
}
get_version

APPIMAGE_EXTRACT_AND_RUN=1 cargo appimage

artifact_name_path="/app/target/appimage"
artifact_name="veridian-controller"
artifact_ext=".AppImage"

full_binary_path="${artifact_name_path}/${artifact_name}${artifact_ext}"
full_versioned_path="${artifact_name_path}/${artifact_name}_${VERSION}${artifact_ext}"
versioned_path="${artifact_name}_${VERSION}${artifact_ext}"

mv -f "${full_binary_path}" "${full_versioned_path}"
echo "" && echo "AppImage release build created at: \"${full_versioned_path}\""

cd /app/target/appimage || exit
sha256sum "${versioned_path}" >"${versioned_path}.sha256"

if [[ "$CI" == false ]]; then
# package to tar.gz when running locally
tar -cvzf veridian-controller_"${VERSION}".tar.gz ./*
fi

0 comments on commit 82d6559

Please sign in to comment.