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) 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