Skip to content

Commit 7218e92

Browse files
committed
initial commit
0 parents  commit 7218e92

File tree

11 files changed

+1135
-0
lines changed

11 files changed

+1135
-0
lines changed

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI - Build and Test
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
EXTENSION_NAME: "aareguru@jon4hz.io"
11+
12+
jobs:
13+
lint-and-validate:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y glib2.0-dev gettext jq curl
24+
25+
- name: Validate JSON files
26+
run: |
27+
echo "Validating metadata.json..."
28+
jq empty metadata.json
29+
30+
echo "Validating schema files..."
31+
find schemas -name "*.xml" -exec xmllint --noout {} \;
32+
33+
- name: Check extension structure
34+
run: |
35+
echo "Checking required files..."
36+
required_files=("extension.js" "prefs.js" "metadata.json" "stylesheet.css")
37+
for file in "${required_files[@]}"; do
38+
if [ ! -f "$file" ]; then
39+
echo "❌ Missing required file: $file"
40+
exit 1
41+
else
42+
echo "✅ Found: $file"
43+
fi
44+
done
45+
46+
echo "Checking schemas directory..."
47+
if [ ! -d "schemas" ]; then
48+
echo "❌ Missing schemas directory"
49+
exit 1
50+
fi
51+
52+
if [ ! -f "schemas/org.gnome.shell.extensions.aareguru.gschema.xml" ]; then
53+
echo "❌ Missing schema file"
54+
exit 1
55+
fi
56+
57+
echo "✅ All required files present"
58+
59+
- name: Compile and validate extension
60+
run: |
61+
make validate
62+
63+
- name: Test build process
64+
run: |
65+
make zip
66+
67+
# Verify the zip contains required files
68+
unzip -l "${EXTENSION_NAME}.zip"
69+
70+
# Extract and verify structure
71+
mkdir -p test-extract
72+
cd test-extract
73+
unzip "../${EXTENSION_NAME}.zip"
74+
75+
# Check for compiled schema
76+
if [ ! -f "schemas/gschemas.compiled" ]; then
77+
echo "❌ Missing compiled schema in package"
78+
exit 1
79+
fi
80+
81+
echo "✅ Extension package validated"

.github/workflows/release.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Build and Release Extension
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Version to release (e.g., 1.2.3)"
11+
required: true
12+
type: string
13+
14+
env:
15+
EXTENSION_NAME: "aareguru@jon4hz.io"
16+
17+
jobs:
18+
build-and-release:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
pull-requests: read
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up dependencies
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y glib2.0-dev gettext zip
34+
35+
- name: Extract version from tag or input
36+
id: version
37+
run: |
38+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
39+
VERSION="${{ github.event.inputs.version }}"
40+
else
41+
VERSION=${GITHUB_REF#refs/tags/v}
42+
fi
43+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
44+
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
45+
echo "Extracted version: $VERSION"
46+
47+
- name: Update metadata.json with version
48+
run: |
49+
VERSION="${{ steps.version.outputs.VERSION }}"
50+
# Update version in metadata.json (keep as string for semantic versioning)
51+
jq --arg version "$VERSION" '.version = $version' metadata.json > metadata.json.tmp
52+
mv metadata.json.tmp metadata.json
53+
54+
echo "Updated metadata.json:"
55+
cat metadata.json
56+
57+
- name: Validate extension
58+
run: |
59+
make validate
60+
61+
- name: Build extension package
62+
id: build
63+
run: |
64+
make zip
65+
66+
# Rename the zip file to include version
67+
VERSION="${{ steps.version.outputs.VERSION }}"
68+
PACKAGE_NAME="${EXTENSION_NAME}-v${VERSION}.zip"
69+
mv "${EXTENSION_NAME}.zip" "$PACKAGE_NAME"
70+
71+
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
72+
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
73+
74+
- name: Generate changelog
75+
id: changelog
76+
run: |
77+
VERSION="${{ steps.version.outputs.VERSION }}"
78+
79+
# Get the previous tag
80+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
81+
82+
if [ -n "$PREV_TAG" ]; then
83+
echo "## Changes since $PREV_TAG" > CHANGELOG.md
84+
echo "" >> CHANGELOG.md
85+
git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD >> CHANGELOG.md
86+
else
87+
echo "## Initial Release" > CHANGELOG.md
88+
echo "" >> CHANGELOG.md
89+
echo "- First release of Aare Guru GNOME Shell Extension" >> CHANGELOG.md
90+
fi
91+
92+
echo "" >> CHANGELOG.md
93+
echo "## Features" >> CHANGELOG.md
94+
echo "- Display water temperature in GNOME Shell panel" >> CHANGELOG.md
95+
echo "- Show detailed water flow and weather information" >> CHANGELOG.md
96+
echo "- Detailed weather forecast for morning, afternoon, and evening" >> CHANGELOG.md
97+
echo "- Water temperature forecast for 2 hours" >> CHANGELOG.md
98+
echo "- Configurable city selection from Swiss measurement stations" >> CHANGELOG.md
99+
echo "- Automatic data updates with configurable intervals" >> CHANGELOG.md
100+
echo "- Color-coded temperature display" >> CHANGELOG.md
101+
echo "- Swiss German interface with consistent UI strings" >> CHANGELOG.md
102+
103+
cat CHANGELOG.md
104+
105+
- name: Create GitHub Release
106+
id: create_release
107+
uses: softprops/action-gh-release@v2
108+
with:
109+
tag_name: ${{ steps.version.outputs.TAG }}
110+
name: "Aare Guru v${{ steps.version.outputs.VERSION }}"
111+
body_path: CHANGELOG.md
112+
files: |
113+
${{ steps.build.outputs.package_name }}
114+
draft: false
115+
prerelease: false
116+
117+
- name: Get release upload URL
118+
id: get_release
119+
run: |
120+
echo "UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT
121+
echo "RELEASE_ID=${{ steps.create_release.outputs.id }}" >> $GITHUB_OUTPUT
122+
echo "RELEASE_URL=${{ steps.create_release.outputs.url }}" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build artifacts
2+
schemas/gschemas.compiled
3+
4+
# Development files
5+
*.log
6+
*.tmp
7+
*~
8+
9+
# IDE files
10+
.vscode/
11+
.idea/
12+
13+
# OS generated files
14+
.DS_Store
15+
.DS_Store?
16+
._*
17+
.Spotlight-V100
18+
.Trashes
19+
ehthumbs.db
20+
Thumbs.db
21+
22+
# Node modules (if using any JS tooling)
23+
node_modules/
24+
npm-debug.log*
25+
26+
# Extension zip for distribution
27+
*.zip

Makefile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Aare Guru GNOME Shell Extension Makefile
2+
3+
EXTENSION_NAME = aareguru@jon4hz.io
4+
BUILD_DIR = build
5+
ZIP_NAME = $(EXTENSION_NAME).zip
6+
7+
# Source files to include in the extension
8+
SOURCES = extension.js prefs.js metadata.json stylesheet.css schemas/
9+
10+
.PHONY: all install uninstall enable disable status prefs clean validate zip help version release lint test
11+
12+
all: compile
13+
14+
compile:
15+
@echo "Compiling GSettings schema..."
16+
glib-compile-schemas schemas/
17+
18+
install: zip
19+
@echo "Installing extension using gnome-extensions..."
20+
gnome-extensions install --force $(ZIP_NAME)
21+
@echo "Extension installed. Please restart GNOME Shell and enable the extension with:"
22+
@echo "gnome-extensions enable $(EXTENSION_NAME)"
23+
24+
uninstall:
25+
@echo "Uninstalling extension using gnome-extensions..."
26+
gnome-extensions uninstall $(EXTENSION_NAME) || echo "Extension was not installed"
27+
@echo "Extension uninstalled."
28+
29+
enable:
30+
@echo "Enabling extension..."
31+
gnome-extensions enable $(EXTENSION_NAME)
32+
@echo "Extension enabled."
33+
34+
disable:
35+
@echo "Disabling extension..."
36+
gnome-extensions disable $(EXTENSION_NAME)
37+
@echo "Extension disabled."
38+
39+
status:
40+
@echo "Extension status:"
41+
@gnome-extensions list --enabled | grep -q $(EXTENSION_NAME) && echo "✅ Enabled" || echo "❌ Disabled"
42+
@gnome-extensions list --user | grep -q $(EXTENSION_NAME) && echo "📦 Installed" || echo "❌ Not installed"
43+
44+
prefs:
45+
@echo "Opening extension preferences..."
46+
gnome-extensions prefs $(EXTENSION_NAME)
47+
48+
clean:
49+
@echo "Cleaning build artifacts..."
50+
rm -f schemas/gschemas.compiled
51+
rm -rf $(BUILD_DIR)
52+
rm -f $(ZIP_NAME)
53+
rm -f $(EXTENSION_NAME)-v*.zip
54+
55+
validate: compile
56+
@echo "Validating extension..."
57+
./scripts/validate.sh
58+
59+
lint:
60+
@echo "Running lint checks..."
61+
@echo "Checking JSON syntax..."
62+
@jq empty metadata.json && echo "✅ metadata.json is valid" || (echo "❌ metadata.json is invalid" && exit 1)
63+
@echo "Checking for common issues..."
64+
@grep -n "console.log" *.js || echo "✅ No console.log statements found"
65+
@grep -n "TODO\|FIXME" *.js || echo "✅ No TODO/FIXME comments found"
66+
67+
test: lint validate
68+
@echo "Running all tests..."
69+
@echo "Testing API connectivity..."
70+
@curl -sf "https://aareguru.existenz.ch/v2018/current?city=bern&app=gnome.shell.extension&version=test" > /dev/null && echo "✅ API is accessible" || echo "⚠️ API might be unavailable"
71+
72+
zip: compile
73+
@echo "Creating extension zip package..."
74+
mkdir -p $(BUILD_DIR)
75+
cp -r $(SOURCES) $(BUILD_DIR)/
76+
cp schemas/gschemas.compiled $(BUILD_DIR)/schemas/
77+
cd $(BUILD_DIR) && zip -r ../$(ZIP_NAME) .
78+
rm -rf $(BUILD_DIR)
79+
@echo "Extension package created: $(ZIP_NAME)"
80+
81+
release: test zip
82+
@echo "Preparing release..."
83+
@VERSION=$$(jq -r '.version' metadata.json); \
84+
VERSIONED_ZIP="$(EXTENSION_NAME)-v$$VERSION.zip"; \
85+
cp $(ZIP_NAME) "$$VERSIONED_ZIP"; \
86+
echo "Release package created: $$VERSIONED_ZIP"; \
87+
echo ""; \
88+
echo "To create a release:"; \
89+
echo "1. Create and push a git tag: git tag v$$VERSION && git push origin v$$VERSION"; \
90+
echo "2. The GitHub Actions workflow will automatically create the release"; \
91+
echo "3. Or manually upload $$VERSIONED_ZIP to GitHub releases"
92+
93+
help:
94+
@echo "Available targets:"
95+
@echo " compile - Compile GSettings schema"
96+
@echo " install - Install extension using gnome-extensions"
97+
@echo " uninstall - Remove extension using gnome-extensions"
98+
@echo " enable - Enable the extension"
99+
@echo " disable - Disable the extension"
100+
@echo " status - Show extension status"
101+
@echo " prefs - Open extension preferences"
102+
@echo " clean - Remove build artifacts"
103+
@echo " lint - Run code linting checks"
104+
@echo " validate - Run validation tests"
105+
@echo " test - Run all tests (lint + validate + API test)"
106+
@echo " zip - Create installable zip package"
107+
@echo " release - Prepare release package"
108+
@echo " help - Show this help message"

0 commit comments

Comments
 (0)