From 7015ce3d025a26aed1b15c053f7ca15141f8c401 Mon Sep 17 00:00:00 2001 From: Ricky Chen Date: Sat, 7 Mar 2026 21:41:30 +0800 Subject: [PATCH 1/2] ci: add GitHub Actions for build check and auto-release --- .github/workflows/ci.yml | 29 +++++++++++++++++++ .github/workflows/release.yml | 53 +++++++++++++++++++++++++++++++++++ Makefile | 5 +++- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..98c4e40 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libjansson-dev libncursesw5-dev nvidia-cuda-toolkit + + - name: Compile check + run: make check + + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Run ShellCheck + run: find scripts -name '*.sh' -exec shellcheck {} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..272de8f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Extract version from tag + id: version + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + + - name: Verify version matches source + run: | + src_version=$(grep '#define NVFD_VERSION' include/nvfd.h | cut -d'"' -f2) + if [ "$src_version" != "${{ steps.version.outputs.version }}" ]; then + echo "ERROR: Tag ${{ github.ref_name }} does not match NVFD_VERSION \"$src_version\" in include/nvfd.h" + exit 1 + fi + + - name: Generate release notes + id: notes + run: | + prev_tag=$(git tag --sort=-v:refname | sed -n '2p') + if [ -n "$prev_tag" ]; then + echo "## Changes since $prev_tag" > notes.md + echo "" >> notes.md + git log "$prev_tag"..HEAD --pretty=format:"- %s" --no-merges >> notes.md + else + echo "## Initial release" > notes.md + fi + echo "" >> notes.md + echo "## Installation" >> notes.md + echo '```bash' >> notes.md + echo "git clone https://github.com/${{ github.repository }}.git" >> notes.md + echo "cd nvfd" >> notes.md + echo "sudo scripts/install.sh" >> notes.md + echo '```' >> notes.md + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: NVFD v${{ steps.version.outputs.version }} + body_path: notes.md + generate_release_notes: false diff --git a/Makefile b/Makefile index 717fb21..38aff1c 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ SRCS = $(wildcard $(SRCDIR)/*.c) OBJS = $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRCS)) TARGET = $(BUILDDIR)/nvfd -.PHONY: all clean install uninstall +.PHONY: all clean check install uninstall all: $(TARGET) @@ -34,6 +34,9 @@ $(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR) $(BUILDDIR): mkdir -p $(BUILDDIR) +check: $(OBJS) + @echo "All source files compiled successfully." + clean: rm -rf $(BUILDDIR) From deed30ea0ba464deb66f37a89aa0b63c6749ec0b Mon Sep 17 00:00:00 2001 From: Ricky Chen Date: Sat, 7 Mar 2026 21:43:25 +0800 Subject: [PATCH 2/2] ci: suppress shellcheck SC1091 for /etc/os-release sourcing --- scripts/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install.sh b/scripts/install.sh index b669448..dac95a9 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -19,6 +19,7 @@ echo # Detect OS if [ -f /etc/os-release ]; then + # shellcheck disable=SC1091 . /etc/os-release OS=$NAME elif type lsb_release >/dev/null 2>&1; then