Skip to content

Commit

Permalink
ci: add simple build test workflow (#696)
Browse files Browse the repository at this point in the history
as well as a dependabot config to update used actions in workflows.

When building from a fork, tags may not exist. Try to obtain latest tag from upstream via GitHub API in this case. Exit early if this fails as well, as DEB packages strictly require their version to start with an integer. For debugging reasons, error output is unmuted.

Signed-off-by: MichaIng <micha@dietpi.com>
  • Loading branch information
MichaIng authored Jan 19, 2025
1 parent f6969e2 commit c8d643b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
target-branch: "master"
labels:
- "enhancement"
19 changes: 19 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build test
on: [pull_request, push, workflow_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
strategy:
matrix:
arch: [armhf, arm64, amd64, riscv64]
fail-fast: false
name: Build on ${{ matrix.arch }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: make ${{ matrix.arch }}
21 changes: 15 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ packages() {

cd librespot

LIBRESPOT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo unknown)"
LIBRESPOT_HASH="$(git rev-parse HEAD | cut -c 1-7 2>/dev/null || echo unknown)"
echo 'Obtaining latest Librespot Git repository tag for DEB package version suffix ...'
LIBRESPOT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" || echo unknown)"
LIBRESPOT_HASH="$(git rev-parse HEAD | cut -c 1-7 || echo unknown)"

echo "Build Librespot binary..."
cargo build --jobs "$(nproc)" --profile release --target "$BUILD_TARGET" --no-default-features --features "alsa-backend pulseaudio-backend with-avahi"
Expand Down Expand Up @@ -156,9 +157,17 @@ START_BUILDS=$(now)

cd /mnt/raspotify

# Get the git rev of raspotify for .deb versioning
RASPOTIFY_GIT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo unknown)"
RASPOTIFY_HASH="$(git rev-parse HEAD | cut -c 1-7 2>/dev/null || echo unknown)"
echo 'Obtaining latest Git repository tag for DEB package version ...'
RASPOTIFY_GIT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" || :)"
if [ -z "$RASPOTIFY_GIT_VER" ]; then
echo 'W: Could not obtain latest tag from local repository. Obtaining it from upstream: https://api.github.com/repos/dtcooper/raspotify/tags'
RASPOTIFY_GIT_VER="$(curl -sSf "https://api.github.com/repos/dtcooper/raspotify/tags" | awk -F\" '/^ *"name": "/{print $4;exit}' || :)"
fi
if [ -z "$RASPOTIFY_GIT_VER" ]; then
echo 'E: Could not obtain latest tag from upstream repository either. Exiting ...'
exit 1
fi
RASPOTIFY_HASH="$(git rev-parse HEAD | cut -c 1-7 || echo unknown)"

echo "Build Raspotify $RASPOTIFY_GIT_VER~$RASPOTIFY_HASH..."

Expand All @@ -181,7 +190,7 @@ case $ARCHITECTURE in
esac

# Fix broken permissions resulting from running the Docker container as root.
[ $(id -u) -eq 0 ] && chown -R "$PERMFIX_UID:$PERMFIX_GID" /mnt/raspotify 2>/dev/null
[ $(id -u) -eq 0 ] && chown -R "$PERMFIX_UID:$PERMFIX_GID" /mnt/raspotify

BUILD_TIME=$(duration_since "$START_BUILDS")

Expand Down

0 comments on commit c8d643b

Please sign in to comment.