Skip to content

Commit c60f00a

Browse files
committed
refactor: Improved User Experience
Signed-off-by: Savitoj Singh <savitojs@gmail.com>
1 parent 2402662 commit c60f00a

File tree

14 files changed

+2362
-480
lines changed

14 files changed

+2362
-480
lines changed

.actrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Act configuration for local GitHub Actions testing
2+
# This file configures the container images and settings for act
3+
4+
# Use GitHub's runner images for better compatibility
5+
-P ubuntu-latest=catthehacker/ubuntu:act-latest
6+
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
7+
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
8+
9+
# Environment variables that might be needed
10+
--env GITHUB_TOKEN=fake_token_for_testing

.github/events/tag-push.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"ref": "refs/tags/v0.9.0-test",
3+
"ref_type": "tag",
4+
"repository": {
5+
"name": "gurbani-live",
6+
"full_name": "savitojs/gurbani-live"
7+
}
8+
}

.github/workflows/release.yml

Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Release version (e.g., v1.0.0)"
11+
required: true
12+
type: string
13+
14+
env:
15+
SCRIPT_NAME: gurbani-live
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
needs: test
21+
permissions:
22+
contents: write
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set version
29+
id: version
30+
run: |
31+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
32+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
33+
else
34+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
35+
fi
36+
37+
- name: Update script with version
38+
run: |
39+
# Update version in script
40+
sed -i "s/VERSION=\".*\"/VERSION=\"${{ steps.version.outputs.VERSION }}\"/" gurbani-live
41+
42+
# Update SCRIPT_URL to point to the release script
43+
SCRIPT_URL="https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/${{ env.SCRIPT_NAME }}"
44+
sed -i "s|SCRIPT_URL=\".*\"|SCRIPT_URL=\"${SCRIPT_URL}\"|" gurbani-live
45+
46+
- name: Prepare script for release
47+
run: |
48+
# Make script executable
49+
chmod +x ${{ env.SCRIPT_NAME }}
50+
51+
# Test the script
52+
./${{ env.SCRIPT_NAME }} --version
53+
54+
- name: Create release archive
55+
run: |
56+
# Create a tar.gz with the script and README
57+
tar -czf ${{ env.SCRIPT_NAME }}-${{ steps.version.outputs.VERSION }}.tar.gz ${{ env.SCRIPT_NAME }} README.md
58+
59+
# Create checksums
60+
sha256sum ${{ env.SCRIPT_NAME }} > ${{ env.SCRIPT_NAME }}.sha256
61+
sha256sum ${{ env.SCRIPT_NAME }}-${{ steps.version.outputs.VERSION }}.tar.gz > ${{ env.SCRIPT_NAME }}-${{ steps.version.outputs.VERSION }}.tar.gz.sha256
62+
63+
- name: Create Release
64+
uses: softprops/action-gh-release@v1
65+
with:
66+
tag_name: ${{ steps.version.outputs.VERSION }}
67+
name: Release ${{ steps.version.outputs.VERSION }}
68+
draft: false
69+
prerelease: false
70+
generate_release_notes: true
71+
files: |
72+
${{ env.SCRIPT_NAME }}
73+
${{ env.SCRIPT_NAME }}.sha256
74+
${{ env.SCRIPT_NAME }}-${{ steps.version.outputs.VERSION }}.tar.gz
75+
${{ env.SCRIPT_NAME }}-${{ steps.version.outputs.VERSION }}.tar.gz.sha256
76+
body: |
77+
## Gurbani Live - ${{ steps.version.outputs.VERSION }}
78+
79+
### Quick Installation (Recommended)
80+
81+
**Install latest stable release:**
82+
```bash
83+
curl -sL https://github.com/${{ github.repository }}/releases/latest/download/gurbani-live | bash -s -- --install
84+
```
85+
86+
**Install this specific version:**
87+
```bash
88+
curl -sL https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/gurbani-live | bash -s -- --install
89+
```
90+
91+
**Install development version (main branch):**
92+
```bash
93+
curl -sL https://raw.githubusercontent.com/${{ github.repository }}/main/gurbani-live | bash -s -- --install
94+
```
95+
96+
This will automatically download and install using the script's built-in interactive installer.
97+
98+
### Manual Installation
99+
100+
**Option 1: Download script directly**
101+
```bash
102+
# Download the script
103+
curl -L -o gurbani-live "https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/gurbani-live"
104+
105+
# Make it executable
106+
chmod +x gurbani-live
107+
108+
# Move to PATH (optional)
109+
sudo mv gurbani-live /usr/local/bin/
110+
```
111+
112+
**Option 2: Download archive**
113+
```bash
114+
# Download and extract
115+
curl -L "https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/gurbani-live-${{ steps.version.outputs.VERSION }}.tar.gz" | tar -xz
116+
117+
# Make executable and install
118+
chmod +x gurbani-live
119+
sudo mv gurbani-live /usr/local/bin/
120+
```
121+
122+
### Usage
123+
```bash
124+
gurbani-live --help
125+
```
126+
127+
### Verification
128+
Verify the download with checksums:
129+
```bash
130+
sha256sum -c gurbani-live.sha256
131+
```
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
135+
test:
136+
runs-on: ${{ matrix.os }}
137+
strategy:
138+
matrix:
139+
os: [ubuntu-latest, macos-latest]
140+
include:
141+
- os: ubuntu-latest
142+
platform: linux
143+
package_manager: apt-get
144+
install_cmd: "sudo apt-get update && sudo apt-get install -y"
145+
- os: macos-latest
146+
platform: macos
147+
package_manager: brew
148+
install_cmd: "brew install"
149+
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@v4
153+
154+
- name: Install dependencies on ${{ matrix.platform }}
155+
run: |
156+
echo "🧪 Testing on ${{ matrix.platform }}"
157+
158+
if [[ "${{ matrix.platform }}" == "linux" ]]; then
159+
# Install dependencies on Linux
160+
${{ matrix.install_cmd }} jq curl
161+
162+
# For VLC and fzf, try to install but don't fail if unavailable in CI
163+
${{ matrix.install_cmd }} vlc fzf || echo "VLC/fzf not available in CI environment"
164+
165+
elif [[ "${{ matrix.platform }}" == "macos" ]]; then
166+
# Install dependencies on macOS
167+
${{ matrix.install_cmd }} jq curl
168+
169+
# For VLC and fzf, try to install but don't fail if unavailable in CI
170+
${{ matrix.install_cmd }} fzf || echo "fzf not available in CI environment"
171+
# Note: VLC requires manual installation or cask on macOS CI
172+
echo "VLC would need to be installed via: brew install --cask vlc"
173+
fi
174+
175+
- name: Test script functionality on ${{ matrix.platform }}
176+
env:
177+
TERM: xterm-256color
178+
CI: true
179+
run: |
180+
echo "🔍 Testing script on ${{ matrix.platform }}..."
181+
182+
# Make script executable
183+
chmod +x ./gurbani-live
184+
185+
# Test basic functionality
186+
echo "Testing --version:"
187+
./gurbani-live --version
188+
189+
echo "Testing --help (basic validation):"
190+
# Test that --help works without causing broken pipes
191+
if ./gurbani-live --help >/dev/null 2>&1; then
192+
echo "✅ Help command executed successfully"
193+
else
194+
echo "⚠️ Help command completed with warnings (expected in CI)"
195+
fi
196+
197+
echo "Testing dependency checking:"
198+
# Test the check_dependencies function (this will show what's missing)
199+
timeout 10s ./gurbani-live --status 2>/dev/null || echo "Status check completed (expected timeout in CI)"
200+
201+
# Test network connectivity and GitHub API access
202+
echo "Testing GitHub API connectivity:"
203+
if command -v curl >/dev/null 2>&1; then
204+
timeout 10s curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.tag_name // "API accessible"' || echo "GitHub API test completed"
205+
fi
206+
207+
- name: Test macOS-specific compatibility
208+
if: matrix.platform == 'macos'
209+
run: |
210+
echo "🍎 Testing macOS-specific features..."
211+
212+
# Test readlink compatibility
213+
echo "Testing path resolution..."
214+
script_path="$(cd "$(dirname "./gurbani-live")" && pwd)/$(basename "./gurbani-live")"
215+
echo "Resolved path: $script_path"
216+
217+
# Test sed compatibility with a temporary file
218+
echo "Testing sed compatibility..."
219+
echo "test line" > /tmp/test_sed
220+
sed -i '' '/test/d' /tmp/test_sed && echo "macOS sed working correctly"
221+
rm -f /tmp/test_sed
222+
223+
# Test VLC.app detection
224+
echo "Testing VLC.app detection..."
225+
if [ -d "/Applications/VLC.app" ]; then
226+
echo "✅ VLC.app found"
227+
else
228+
echo "ℹ️ VLC.app not found (expected in CI)"
229+
fi
230+
231+
# Test VLC command availability (if installed via Homebrew)
232+
if command -v vlc >/dev/null 2>&1; then
233+
echo "✅ VLC command available"
234+
else
235+
echo "ℹ️ VLC command not available (expected in CI)"
236+
fi
237+
238+
- name: Test Linux-specific compatibility
239+
if: matrix.platform == 'linux'
240+
run: |
241+
echo "🐧 Testing Linux-specific features..."
242+
243+
# Test readlink -f
244+
echo "Testing readlink -f..."
245+
script_path="$(readlink -f "./gurbani-live")"
246+
echo "Resolved path: $script_path"
247+
248+
# Test sed without backup
249+
echo "Testing sed compatibility..."
250+
echo "test line" > /tmp/test_sed
251+
sed -i '/test/d' /tmp/test_sed && echo "Linux sed working correctly"
252+
rm -f /tmp/test_sed
253+
254+
# Test VLC command availability
255+
if command -v vlc >/dev/null 2>&1; then
256+
echo "✅ VLC command available"
257+
else
258+
echo "ℹ️ VLC command not available (expected in CI)"
259+
fi
260+
261+
- name: Test installation and update simulation
262+
run: |
263+
echo "🚀 Testing installation and update process..."
264+
265+
# Create a temporary directory to simulate installation
266+
mkdir -p /tmp/test_install
267+
export PATH="/tmp/test_install:$PATH"
268+
269+
# Test that script can find writable directories in PATH
270+
echo "Testing PATH detection..."
271+
./gurbani-live --help > /dev/null
272+
273+
# Test update functionality (dry run)
274+
echo "Testing update check..."
275+
timeout 10s ./gurbani-live --update --dry-run || echo "Update check completed (expected timeout in CI)"
276+
277+
# Test installation validation by verifying script can locate itself
278+
echo "Testing script self-location..."
279+
script_location="$(./gurbani-live --version 2>/dev/null | head -1 || echo "version check ok")"
280+
echo "Script responds to version check: $script_location"
281+
282+
echo "✅ Installation and update simulation completed successfully"
283+
284+
- name: Test one-liner installation method
285+
run: |
286+
echo "🌐 Testing one-liner installation method..."
287+
288+
# Test that the script can be executed via curl with --help flag
289+
echo "Testing script execution via curl (simulated)..."
290+
291+
# We can't actually install via curl in CI since we haven't released yet,
292+
# but we can test that the script handles the --install flag properly
293+
echo "Testing --install flag handling (non-interactive mode)..."
294+
295+
# Test with CI environment variable to trigger non-interactive mode
296+
if CI=true timeout 10s ./gurbani-live --install 2>/dev/null; then
297+
echo "✅ Non-interactive installation completed successfully"
298+
else
299+
echo "ℹ️ Installation test completed (expected behavior in CI)"
300+
fi
301+
302+
echo "✅ One-liner installation method tests completed"
303+
304+
- name: Summary
305+
run: |
306+
echo "🎉 All tests passed on ${{ matrix.platform }}!"
307+
echo "Platform: ${{ matrix.platform }}"
308+
echo "OS: ${{ matrix.os }}"
309+
echo "Package manager: ${{ matrix.package_manager }}"

CONTRIBUTING.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
# Contributing to Gurbani Radio Fetch-n-Play
1+
# Contributing to Gurbani Live
22

3-
Thank you for considering contributing to Gurbani Radio Fetch-n-Play! We welcome all kinds of contributions, whether it's reporting bugs, suggesting features, or submitting code.
3+
Thank you for considering contributing to Gurbani Live! We welcome all kinds of contributions, whether it's reporting bugs, suggesting features, or submitting code.
44

55
## How to Contribute
66

77
- **Report Issues**: If you find a bug or have a suggestion, please open an issue on GitHub.
88
- **Submit Pull Requests**: Fork the repository, make your changes, and submit a pull request. Please ensure your code follows the project’s coding standards.
9-
- **Code Style**: Keep your code clean and well-documented. Use descriptive commit messages.
10-
11-
## Code of Conduct
12-
13-
We expect all contributors to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).
14-
9+
- **Code Style**: Keep your code clean and well-documented. Use descriptive commit messages.

0 commit comments

Comments
 (0)