Skip to content

Commit f928151

Browse files
authored
Merge pull request #2 from MehmetNuri/develop
ci: add GitHub Actions (build + release) and build.sh
2 parents 541d173 + f30442a commit f928151

4 files changed

Lines changed: 107 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install tools
16+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libglib2.0-bin gettext zip
17+
18+
- name: JavaScript syntax check
19+
run: |
20+
node --check extension.js
21+
node --check prefs.js
22+
23+
- name: Build (validates JSON, schema and translations, then packs)
24+
run: sh build.sh
25+
26+
- name: Upload extension zip
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: audio-output-switcher
30+
path: dist/*.shell-extension.zip
31+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
# Push a tag like v1, v2, v3 to build the zip and attach it to a GitHub Release.
4+
on:
5+
push:
6+
tags: [ 'v*' ]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install tools
18+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libglib2.0-bin gettext zip
19+
20+
- name: JavaScript syntax check
21+
run: |
22+
node --check extension.js
23+
node --check prefs.js
24+
25+
- name: Build zip
26+
run: sh build.sh
27+
28+
- name: Create GitHub Release with the zip
29+
env:
30+
GH_TOKEN: ${{ github.token }}
31+
run: gh release create "${GITHUB_REF_NAME}" dist/*.shell-extension.zip --generate-notes

build.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
# Build the EGO-compliant extension zip into dist/.
3+
# Does NOT require gnome-shell; uses zip + gettext + glib tools only.
4+
# Layout matches extensions.gnome.org rules: metadata.json at the root, schema
5+
# XML only (no gschemas.compiled), compiled translations, no build files.
6+
set -eu
7+
8+
UUID="audio-output-switcher@mehmetnuri.github.io"
9+
DOMAIN="audio-output-switcher"
10+
ZIP="dist/$UUID.shell-extension.zip"
11+
12+
for t in zip msgfmt glib-compile-schemas; do
13+
command -v "$t" >/dev/null 2>&1 || { echo "ERROR: '$t' not found"; exit 1; }
14+
done
15+
16+
# 1. Validate metadata.json
17+
if command -v python3 >/dev/null 2>&1; then
18+
python3 -c "import json,sys; json.load(open('metadata.json'))" \
19+
|| { echo "ERROR: metadata.json is not valid JSON"; exit 1; }
20+
fi
21+
22+
# 2. Validate the GSettings schema (strict). The compiled output is NOT shipped.
23+
glib-compile-schemas --strict schemas/ >/dev/null
24+
rm -f schemas/gschemas.compiled
25+
26+
# 3. Compile translations po/*.po -> locale/<lang>/LC_MESSAGES/<domain>.mo
27+
for po in po/*.po; do
28+
[ -e "$po" ] || continue
29+
lang=$(basename "$po" .po)
30+
mkdir -p "locale/$lang/LC_MESSAGES"
31+
msgfmt --check "$po" -o "locale/$lang/LC_MESSAGES/$DOMAIN.mo"
32+
done
33+
34+
# 4. Assemble the zip
35+
mkdir -p dist
36+
rm -f "$ZIP"
37+
zip -qX "$ZIP" metadata.json extension.js prefs.js LICENSE
38+
zip -qX "$ZIP" schemas/*.gschema.xml
39+
zip -qX "$ZIP" locale/*/LC_MESSAGES/*.mo
40+
41+
echo "Built $ZIP"
42+
unzip -l "$ZIP"

extension.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ class OutputSwitcherPopup extends SwitcherPopup.SwitcherPopup {
234234
}
235235

236236
_keyPressHandler(keysym, action) {
237-
if (action == this._action)
237+
if (action === this._action)
238238
this._select(this._next());
239-
else if (keysym == Clutter.KEY_Right || keysym == Clutter.KEY_Down)
239+
else if (keysym === Clutter.KEY_Right || keysym === Clutter.KEY_Down)
240240
this._select(this._next());
241-
else if (keysym == Clutter.KEY_Left || keysym == Clutter.KEY_Up)
241+
else if (keysym === Clutter.KEY_Left || keysym === Clutter.KEY_Up)
242242
this._select(this._previous());
243243
else
244244
return Clutter.EVENT_PROPAGATE;

0 commit comments

Comments
 (0)