Skip to content

Commit d35efca

Browse files
authored
Merge pull request #20 from shakg/fix/build-parallel
Fix/build parallel
2 parents b583de4 + fcb23b0 commit d35efca

28 files changed

Lines changed: 2072 additions & 128 deletions

.github/workflows/release.yml

Lines changed: 75 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,77 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-latest, macos-latest]
1817
include:
1918
- os: ubuntu-latest
20-
artifact_suffix: linux
19+
artifact_suffix: linux-x86_64
20+
archive_name: g-systemctl-linux-x86_64.tar.gz
2121
- os: macos-latest
2222
artifact_suffix: macos
23+
archive_name: g-systemctl-macos.tar.gz
2324

2425
steps:
2526
- name: Checkout code
2627
uses: actions/checkout@v4
2728

2829
- name: Install dependencies (Linux)
29-
if: matrix.os == 'ubuntu-latest'
30+
if: runner.os == 'Linux'
3031
run: |
3132
sudo apt-get update
3233
sudo apt-get install -y cmake build-essential
3334
3435
- name: Install dependencies (macOS)
35-
if: matrix.os == 'macos-latest'
36+
if: runner.os == 'macOS'
3637
run: brew install cmake
3738

38-
- name: Configure and Build
39+
- name: Get version
40+
id: version
41+
shell: bash
42+
run: |
43+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
44+
echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "VERSION=0.0.0-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
47+
fi
48+
49+
- name: Configure and build
50+
run: |
51+
cmake -S . -B build \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-DG_SYSTEMCTL_VERSION=${{ steps.version.outputs.VERSION }}
54+
cmake --build build --config Release --parallel
55+
56+
- name: Package binary archive
57+
shell: bash
58+
run: |
59+
mkdir -p dist/g-systemctl-${{ steps.version.outputs.VERSION }}
60+
cp build/g-systemctl dist/g-systemctl-${{ steps.version.outputs.VERSION }}/
61+
chmod +x dist/g-systemctl-${{ steps.version.outputs.VERSION }}/g-systemctl
62+
tar -czf dist/${{ matrix.archive_name }} -C dist g-systemctl-${{ steps.version.outputs.VERSION }}
63+
64+
- name: Build Debian package
65+
if: runner.os == 'Linux'
66+
shell: bash
67+
run: |
68+
cmake --build build --target package --config Release
69+
deb_package="$(find build -maxdepth 1 -name '*.deb' -print -quit)"
70+
cp "$deb_package" dist/g-systemctl-linux-amd64.deb
71+
72+
- name: Generate checksums
73+
shell: bash
3974
run: |
40-
mkdir -p build
41-
cd build
42-
cmake -DCMAKE_BUILD_TYPE=Release ..
43-
make -j$(nproc)
75+
cd dist
76+
for file in *; do
77+
if [[ -f "$file" ]]; then
78+
shasum -a 256 "$file"
79+
fi
80+
done > SHA256SUMS-${{ matrix.artifact_suffix }}.txt
4481
4582
- name: Upload artifact
4683
uses: actions/upload-artifact@v4
4784
with:
4885
name: g-systemctl-${{ matrix.artifact_suffix }}
49-
path: build/g-systemctl
86+
path: dist/*
87+
if-no-files-found: error
5088

5189
create-release:
5290
needs: build
@@ -59,34 +97,45 @@ jobs:
5997

6098
- name: Get version
6199
id: version
62-
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
100+
run: |
101+
echo "TAG=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
102+
echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
63103
64-
- name: Download Linux artifact
104+
- name: Download artifacts
65105
uses: actions/download-artifact@v4
66106
with:
67-
name: g-systemctl-linux
68-
path: artifacts/linux
107+
path: artifacts
108+
merge-multiple: true
69109

70-
- name: Download macOS artifact
71-
uses: actions/download-artifact@v4
72-
with:
73-
name: g-systemctl-macos
74-
path: artifacts/macos
110+
- name: Generate Homebrew formula
111+
shell: bash
112+
run: |
113+
source_url="https://github.com/shakg/g-systemctl/archive/refs/tags/${{ steps.version.outputs.TAG }}.tar.gz"
114+
source_sha="$(curl -L "$source_url" | shasum -a 256 | awk '{print $1}')"
115+
sed \
116+
-e "s|refs/tags/v1.0.0.tar.gz|refs/tags/${{ steps.version.outputs.TAG }}.tar.gz|" \
117+
-e "s|REPLACE_WITH_RELEASE_TARBALL_SHA256|${source_sha}|" \
118+
Formula/g-systemctl.rb > artifacts/g-systemctl.rb
75119
76-
- name: Make artifacts executable
120+
- name: Generate combined checksums
77121
run: |
78-
chmod +x artifacts/linux/g-systemctl
79-
chmod +x artifacts/macos/g-systemctl
122+
cd artifacts
123+
shasum -a 256 g-systemctl-linux-x86_64.tar.gz g-systemctl-macos.tar.gz g-systemctl-linux-amd64.deb g-systemctl.rb > SHA256SUMS.txt
80124
81125
- name: Create Release
82126
uses: softprops/action-gh-release@v2
83127
with:
84-
tag_name: ${{ steps.version.outputs.VERSION }}
85-
name: Release ${{ steps.version.outputs.VERSION }}
128+
tag_name: ${{ steps.version.outputs.TAG }}
129+
name: Release ${{ steps.version.outputs.TAG }}
86130
draft: false
87131
prerelease: false
88132
files: |
89-
artifacts/linux/g-systemctl
90-
artifacts/macos/g-systemctl
133+
artifacts/g-systemctl-linux-x86_64.tar.gz
134+
artifacts/g-systemctl-macos.tar.gz
135+
artifacts/g-systemctl-linux-amd64.deb
136+
artifacts/g-systemctl.rb
137+
artifacts/SHA256SUMS.txt
138+
artifacts/SHA256SUMS-linux-x86_64.txt
139+
artifacts/SHA256SUMS-macos.txt
91140
env:
92141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
cmake_minimum_required(VERSION 3.14)
2+
3+
set(G_SYSTEMCTL_VERSION "1.0.0" CACHE STRING "g-systemctl release version")
4+
25
project(g-systemctl
3-
VERSION 1.0.0
6+
VERSION ${G_SYSTEMCTL_VERSION}
47
LANGUAGES CXX
58
DESCRIPTION "Terminal UI for system service management"
69
)
@@ -16,6 +19,7 @@ endif()
1619
add_compile_options(-Wall -Wextra -Wpedantic)
1720

1821
include(cmake/FetchFTXUI.cmake)
22+
find_package(Threads REQUIRED)
1923

2024
option(BUILD_TESTING "Enable unit testing" OFF)
2125

@@ -39,10 +43,15 @@ target_include_directories(g-systemctl PRIVATE
3943
${PROJECT_SOURCE_DIR}/include
4044
)
4145

46+
target_compile_definitions(g-systemctl PRIVATE
47+
G_SYSTEMCTL_VERSION="${PROJECT_VERSION}"
48+
)
49+
4250
target_link_libraries(g-systemctl PRIVATE
4351
ftxui::screen
4452
ftxui::dom
4553
ftxui::component
54+
Threads::Threads
4655
)
4756

4857
if(BUILD_TESTING)
@@ -51,3 +60,26 @@ if(BUILD_TESTING)
5160
endif()
5261

5362
install(TARGETS g-systemctl RUNTIME DESTINATION bin)
63+
64+
set(CPACK_PACKAGE_NAME "g-systemctl")
65+
set(CPACK_PACKAGE_VENDOR "shakg")
66+
set(CPACK_PACKAGE_CONTACT "shakg")
67+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
68+
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
69+
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/shakg/g-systemctl")
70+
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
71+
72+
if(UNIX AND NOT APPLE)
73+
set(CPACK_GENERATOR "TGZ;DEB")
74+
else()
75+
set(CPACK_GENERATOR "TGZ")
76+
endif()
77+
78+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "shakg")
79+
set(CPACK_DEBIAN_PACKAGE_SECTION "admin")
80+
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
81+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
82+
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
83+
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "g-systemctl is a terminal user interface for browsing, filtering, and controlling system services.")
84+
85+
include(CPack)

Formula/g-systemctl.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class GSystemctl < Formula
2+
desc "Terminal UI for managing system services"
3+
homepage "https://github.com/shakg/g-systemctl"
4+
url "https://github.com/shakg/g-systemctl/archive/refs/tags/v1.0.0.tar.gz"
5+
sha256 "REPLACE_WITH_RELEASE_TARBALL_SHA256"
6+
license "MIT"
7+
head "https://github.com/shakg/g-systemctl.git", branch: "main"
8+
9+
depends_on "cmake" => :build
10+
11+
def install
12+
system "cmake", "-S", ".", "-B", "build",
13+
"-DCMAKE_BUILD_TYPE=Release",
14+
"-DG_SYSTEMCTL_VERSION=#{version}",
15+
*std_cmake_args
16+
system "cmake", "--build", "build", "--parallel"
17+
system "cmake", "--install", "build"
18+
end
19+
20+
test do
21+
assert_match version.to_s, shell_output("#{bin}/g-systemctl --version")
22+
end
23+
end

Makefile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
.PHONY: build test clean
1+
BUILD_DIR ?= build
2+
BUILD_TYPE ?= Release
3+
JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
24

3-
build:
4-
rm -rf build && mkdir build && cd build && cmake -DBUILD_TESTING=ON .. && make -j4
5+
.PHONY: all configure build run test install clean distclean
6+
7+
all: build
8+
9+
configure:
10+
cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
11+
12+
build: configure
13+
cmake --build $(BUILD_DIR) --parallel $(JOBS)
14+
15+
run: build
16+
cd $(BUILD_DIR) && ./g-systemctl
517

618
test:
7-
cd build/tests && ./g-systemctl-tests 2>&1 && ctest --output-on-failure
19+
cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DBUILD_TESTING=ON
20+
cmake --build $(BUILD_DIR) --parallel $(JOBS)
21+
ctest --test-dir $(BUILD_DIR) --output-on-failure
22+
23+
install: build
24+
cmake --install $(BUILD_DIR)
825

926
clean:
10-
rm -rf build
27+
cmake --build $(BUILD_DIR) --target clean
28+
29+
distclean:
30+
rm -rf $(BUILD_DIR)

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ g-systemctl is a terminal user interface (TUI) for managing system services on L
3030

3131
## Installation
3232

33+
### Homebrew
34+
35+
Download the formula from the latest release and install it locally:
36+
37+
```bash
38+
curl -LO https://github.com/shakg/g-systemctl/releases/latest/download/g-systemctl.rb
39+
brew install ./g-systemctl.rb
40+
```
41+
42+
### Debian / Ubuntu
43+
44+
Download the `.deb` package from the latest release and install it:
45+
46+
```bash
47+
curl -LO https://github.com/shakg/g-systemctl/releases/latest/download/g-systemctl-linux-amd64.deb
48+
sudo apt install ./g-systemctl-linux-amd64.deb
49+
```
50+
51+
### Linux Binary
52+
53+
```bash
54+
curl -LO https://github.com/shakg/g-systemctl/releases/latest/download/g-systemctl-linux-x86_64.tar.gz
55+
tar -xzf g-systemctl-linux-x86_64.tar.gz
56+
sudo install -m 755 g-systemctl-*/g-systemctl /usr/local/bin/g-systemctl
57+
```
58+
3359
### Build from source
3460

3561
```bash
@@ -41,10 +67,11 @@ make -j$(nproc)
4167
sudo make install
4268
```
4369

44-
### One-Line Release Download
70+
### Release Checksums
4571

4672
```bash
47-
curl https://api.github.com/repos/shakg/g-systemctl/releases/latest | jq '.assets[0].browser_download_url' | xargs wget
73+
curl -LO https://github.com/shakg/g-systemctl/releases/latest/download/SHA256SUMS.txt
74+
grep g-systemctl-linux-x86_64.tar.gz SHA256SUMS.txt | shasum -a 256 -c -
4875
```
4976

5077
## Usage
@@ -66,10 +93,10 @@ sudo g-systemctl
6693
| `Up` / `k` | Move selection up |
6794
| `Down` / `j` | Move selection down |
6895
| `Enter` | Toggle selected service (start/stop) |
69-
| `r` | Refresh service list |
70-
| `l` | Open logs for selected service (tmux only) |
96+
| `Alt+r` | Restart selected service |
97+
| `Alt+l` | Open logs for selected service (tmux only) |
7198
| `?` | Show/hide help |
72-
| `q` / `Esc` | Quit |
99+
| `Alt+q` / `Esc` | Quit |
73100
| Type | Filter services by name |
74101
| `Backspace` | Delete filter character |
75102

@@ -85,7 +112,8 @@ sudo g-systemctl
85112
```bash
86113
g-systemctl --help # Show help
87114
g-systemctl --version # Show version
88-
g-systemctl --system # Show system services instead of user services
115+
g-systemctl --system # Show system services (default)
116+
g-systemctl --user # Show user services
89117
g-systemctl -f <text> # Start with an initial filter
90118
g-systemctl --filter <text> # Start with an initial filter
91119
```

docs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ git tag v1.0.0
5959
git push origin v1.0.0
6060
```
6161

62-
This will trigger the release workflow, which builds binaries for Linux and macOS and creates a GitHub Release with the artifacts attached.
62+
This will trigger the release workflow, which builds binaries for Linux and macOS and creates a GitHub Release with the artifacts attached.

0 commit comments

Comments
 (0)