Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
jobs:
build:
name: Build and test (${{ matrix.tools }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
tools: [arch/x86_64, arch/armv7/cortex-m4, arch/armv7/cortex-m7]
container:
image: chocotechnologies/dmod:1.0.4
steps:
- uses: actions/checkout@v4
- name: Build
run: |
cmake -S . -B build -DDMOD_TOOLS_NAME=${{ matrix.tools }}
cmake --build build --parallel 4
test -f build/dmf/dmutc.dmf
test -f build/dmf/test_dmutc.dmf
- name: Native tests
if: matrix.tools == 'arch/x86_64'
run: ctest --test-dir build --output-on-failure
279 changes: 279 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
name: Release

on:
release:
types: [created]

jobs:
discover-architectures:
name: Discover Architectures
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: chocotechnologies/dmod:1.0.4
outputs:
architectures: ${{ steps.list-archs.outputs.architectures }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Fetch dmod to discover architectures
run: |
# A plain `git clone` here (rather than configuring dmutc's
# own CMakeLists.txt via FetchContent, as before) so this step only
# ever depends on dmod itself - not on dmutc's
# dmod_link_modules() fetches of other modules, which this step has
# no business needing just to list dmod's supported architectures,
# and which previously made this discovery job (and therefore the
# whole release) fail outright whenever any of those unrelated
# external fetches hiccuped.
git clone --depth 1 https://github.com/choco-technologies/dmod.git dmod_discovery

- name: List available architectures
id: list-archs
run: |
# create JSON array
ARCHS=$(find dmod_discovery/configs/arch -name "tools-cfg.cmake" | \
sed "s|dmod_discovery/configs/arch/||g" | \
sed 's|/tools-cfg.cmake||g' | \
jq -R -s -c 'split("\n") | map(select(length > 0))')

echo "Found architectures: $ARCHS"
echo "architectures=$ARCHS" >> $GITHUB_OUTPUT

build-release:
name: Build Release for ${{ matrix.arch_name }}
needs: discover-architectures
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
arch_name: ${{ fromJson(needs.discover-architectures.outputs.architectures) }}

container:
image: chocotechnologies/dmod:1.0.4

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Extract version from tag
id: get_version
run: |
# Extract version from tag (e.g., v1.2 -> 1.2)
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}" # Remove 'v' prefix if present
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"

- name: Build dmutc for ${{ matrix.arch_name }}
run: |
set -e
ARCH_DIR_NAME=$(echo "${{ matrix.arch_name }}" | sed 's|/|-|')
echo "ARCH_DIR_NAME=$ARCH_DIR_NAME" >> $GITHUB_ENV
echo "ARTIFACT_NAME=release-$ARCH_DIR_NAME" >> $GITHUB_ENV
mkdir -p build_$ARCH_DIR_NAME
cd build_$ARCH_DIR_NAME

# DMOD_DMR_PATH is already set in CMakeLists.txt, so this build also
# assembles build_$ARCH_DIR_NAME/packages/<module>/ for every module
# defined in this repo's CMake config - nothing left to do here but
# discover whatever got packaged, add release notes, and zip it.
cmake .. -DDMOD_TOOLS_NAME=arch/${{ matrix.arch_name }} -DDMOD_MODULE_VERSION="${{ steps.get_version.outputs.version }}"
cmake --build .

echo "Build completed for ${{ matrix.arch_name }}"
ls -la packages/

- name: Add release notes and create release archives
run: |
set -e
BUILD_DIR="build_$ARCH_DIR_NAME"
TAG="${{ github.event.release.tag_name }}"
PACKAGES_DIR="$BUILD_DIR/packages"

if [ ! -d "$PACKAGES_DIR" ] || [ -z "$(ls -A "$PACKAGES_DIR")" ]; then
echo "Error: no packages found in $PACKAGES_DIR"
exit 1
fi

# A repo may define more than one module (e.g. a core + port split,
# or several independent modules) - package every subdirectory
# found under packages/, not just dmutc.
: > package-names.txt
for pkg_dir in "$PACKAGES_DIR"/*/; do
pkg=$(basename "$pkg_dir")
echo "$pkg" >> package-names.txt

echo "${{ github.event.release.body }}" > "${pkg_dir}RELEASE_NOTES.txt"
(cd "$pkg_dir" && zip -r "${OLDPWD}/${pkg}-${TAG}-${ARCH_DIR_NAME}.zip" .)
done

echo "Created archives:"
ls -lh *-"${TAG}"-"${ARCH_DIR_NAME}".zip
echo "Packages found:"
cat package-names.txt

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
*.zip
package-names.txt
retention-days: 1

generate-versions-manifest:
name: Generate versions.dmm
needs: [discover-architectures, build-release]
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history to get all tags

- name: Download release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Generate versions.dmm
run: |
set -e
echo "# List of available versions for dmutc modules" > versions.dmm
echo "# Generated automatically by CI" >> versions.dmm
echo "" >> versions.dmm

# Get all version tags (starting with 'v') and extract version numbers
VERSIONS=$(git tag -l 'v*' | sed 's/^v//' | sort -V | tr '\n' ' ' | sed 's/ $//')

# Remove vlatest from the list if present
VERSIONS=$(echo $VERSIONS | sed 's/\blatest\b//g' | xargs)

if [ -z "$VERSIONS" ]; then
echo "Warning: No version tags found"
VERSIONS="${{ github.event.release.tag_name }}"
VERSIONS="${VERSIONS#v}"
fi

echo "Found versions: $VERSIONS"

# Union of package names discovered across every architecture build
# (the same set is expected everywhere, but union is safe even if
# some packages only exist for a subset of architectures).
PACKAGES=$(cat artifacts/release-*/package-names.txt | sort -u)
echo "Found packages: $PACKAGES"

for pkg in $PACKAGES; do
echo "\$version-available $pkg $VERSIONS" >> versions.dmm
done

echo "Generated versions.dmm:"
cat versions.dmm

- name: Upload versions.dmm as artifact
uses: actions/upload-artifact@v4
with:
name: versions-manifest
path: versions.dmm
retention-days: 1

upload-release-assets:
name: Upload Release Assets
needs: [build-release, generate-versions-manifest]
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Display artifact structure
run: |
echo "Downloaded artifacts:"
ls -lR artifacts/

- name: Upload release assets to versioned tag
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
shopt -s nullglob
zip_files=(artifacts/release-*/*.zip)

if [ ${#zip_files[@]} -eq 0 ]; then
echo "Error: No artifacts found to upload"
exit 1
fi

for zip_file in "${zip_files[@]}"; do
echo "Uploading $zip_file to ${{ github.event.release.tag_name }}..."
gh release upload ${{ github.event.release.tag_name }} \
"$zip_file" \
--repo ${{ github.repository }} \
--clobber
done

if [ -f artifacts/versions-manifest/versions.dmm ]; then
echo "Uploading versions.dmm to ${{ github.event.release.tag_name }}..."
gh release upload ${{ github.event.release.tag_name }} \
artifacts/versions-manifest/versions.dmm \
--repo ${{ github.repository }} \
--clobber
fi

echo "Successfully uploaded ${#zip_files[@]} artifact(s) to ${{ github.event.release.tag_name }}"

- name: Create or update latest release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
if gh release view vlatest --repo ${{ github.repository }} >/dev/null 2>&1; then
echo "Release vlatest exists, deleting it..."
gh release delete vlatest --repo ${{ github.repository }} --yes
fi

echo "Creating vlatest release..."
gh release create vlatest \
--repo ${{ github.repository }} \
--title "Latest Release (based on ${{ github.event.release.tag_name }})" \
--notes "This release always points to the latest stable version. Currently based on ${{ github.event.release.tag_name }}."

- name: Upload release assets to latest tag
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
shopt -s nullglob
zip_files=(artifacts/release-*/*.zip)

for zip_file in "${zip_files[@]}"; do
echo "Uploading $zip_file to vlatest..."
gh release upload vlatest \
"$zip_file" \
--repo ${{ github.repository }} \
--clobber
done

if [ -f artifacts/versions-manifest/versions.dmm ]; then
echo "Uploading versions.dmm to vlatest..."
gh release upload vlatest \
artifacts/versions-manifest/versions.dmm \
--repo ${{ github.repository }} \
--clobber
fi

echo "Successfully uploaded ${#zip_files[@]} artifact(s) to vlatest"
32 changes: 14 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
# Build directories
build/
*.dmf
*.dmfc

# CLion
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#cmake-build-*
# IDE
# .vscode/tasks.json and .vscode/settings.json are committed (see every real
# module repo) so the build tasks are shared with the team - don't ignore
# .vscode/ wholesale.
.idea/

# Temporary files
*.tmp
*.swp
*~
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.associations": {
"dmutc.h": "c"
},
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"C_Cpp.intelliSenseEngine": "default",
"C_Cpp.errorSquiggles": "enabled"
}
Loading
Loading