diff --git a/.github/workflows/dist-tarball.yml b/.github/workflows/dist-tarball.yml new file mode 100644 index 0000000..aa5a0f3 --- /dev/null +++ b/.github/workflows/dist-tarball.yml @@ -0,0 +1,41 @@ +name: dist-tarball +on: + push: + branches: [ main ] + tags: [ 'v*' ] + pull_request: + branches: [ main ] + paths: [ .github/workflows/dist-tarball.yml, meson.build ] + +jobs: + dist-tarball: + runs-on: ubuntu-26.04-arm + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Setup + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y meson + echo "/usr/lib/llvm-21/bin" >> $GITHUB_PATH + + - name: meson setup + run: | + meson setup --cross-file=./llvm.ini build + + - name: meson dist + run: | + meson dist -C build + + - name: Query version + run: | + meson introspect --projectinfo build | jq -r '"VERSION=\(.["version"])"' >> $GITHUB_ENV + + - uses: actions/upload-artifact@v7 + with: + archive: false + path: build/meson-dist/avd-fw-${{ env.VERSION }}.tar.xz diff --git a/meson.build b/meson.build index 59cbba4..6a4f077 100644 --- a/meson.build +++ b/meson.build @@ -3,9 +3,12 @@ project('avd-fw', 'c', license: 'MIT', license_files: 'LICENSE', meson_version: '>=1.4.0', - version: '0.1', + version: run_command('version.sh', 'get-vcs', check: true).stdout().strip(), ) +# Provide a version for `meson dist` tarballs +meson.add_dist_script('version.sh', 'set-dist', meson.project_version()) + # cross files are needed as those are the only way to set default compiler # and specify the host arch if not meson.is_cross_build() diff --git a/version.sh b/version.sh new file mode 100755 index 0000000..ce0310d --- /dev/null +++ b/version.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ "$1" = "get-vcs" ]; then + GIT_DIR="${MESON_SOURCE_ROOT}"/.git + if [ ! -e "${GIT_DIR}" ]; then + echo "Tarball either not created with \`meson dist\` or otherwise missing \"${GIT_DIR}\"." + exit 1 + fi + git --git-dir "$MESON_SOURCE_ROOT"/.git describe --always --dirty +elif [ "$1" = "set-dist" ]; then + $MESONREWRITE --sourcedir="$MESON_PROJECT_DIST_ROOT" kwargs set project / version "$2" +else + echo "$0 is expected to be executed by meson with 'get-vcs' or 'set-dist ...' as command" + exit 1 +fi