Skip to content

Commit

Permalink
run: fix git describe
Browse files Browse the repository at this point in the history
Full git tree was missing in CI for non-tagged builds
  • Loading branch information
gsanchietti committed Feb 1, 2024
1 parent 9e2a71e commit 4c5b89a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ jobs:
NETIFYD_ACCESS_TOKEN: ${{ secrets.NETIFYD_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: read_tag
name: Set VERSION env variable
if: ${{ startsWith(github.ref, 'refs/tags') }}
run: |
# Set tag from GitHub: using git describe in this context seems not working
# even if the checkout has been done with fetch-depth set to 0
# Set tag from GitHub: using git describe for tags inside the run script
# seems not working
echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- id: build
name: Build the image
Expand Down
9 changes: 6 additions & 3 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ fi
# Download latest image
podman pull $image

# Renove existing container
# Remove existing container
if [ "$(podman ps -a --format '{{.Names}}')" == "nethsec-builder" ]; then
podman rm nethsec-builder
fi

# Use VERSION from the environment, need for CI
# VERSION has the following format: 8-<owrt_release>-ns.<nethsecurity_release>[-<commit_since_last_tag>-g<commit_hash>]
if [ -z "{$VERSION}" ]; then
if [ -z "${VERSION}" ]; then
# Setup version from git if the env var is not set
VERSION=$(git describe --tags)
# Make sure to fetch all history to generate a correct git-descrive
git fetch --prune --unshallow
VERSION=$(git describe)
fi
# OWRT_VERSION is like 23.05.2
OWRT_VERSION=$(echo $VERSION | cut -d'-' -f1)
Expand All @@ -83,6 +85,7 @@ fi
export REPO_CHANNEL
export OWRT_VERSION
export VERSION
echo "Building version $VERSION"

# Setup CI when pushing to Github.
if [[ -n "${CI}" ]]; then
Expand Down

0 comments on commit 4c5b89a

Please sign in to comment.