Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
149 changes: 149 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:
workflow_call: # réutilisé par release.yml avant de publier

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Scripts exécutés par Android (/system/bin/sh = mksh)
MODULE_SCRIPTS: caros_config.sh post-fs-data.sh service.sh grant_permissions.sh META-INF/com/google/android/update-binary

jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ShellCheck (scripts du module, dialecte ksh/mksh)
run: |
# shellcheck disable=SC2086 # découpage voulu de la liste
shellcheck --shell=ksh --severity=warning $MODULE_SCRIPTS
- name: ShellCheck (build.sh, bash)
run: shellcheck --shell=bash --severity=warning build.sh

syntax:
name: Syntax (mksh / bash)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mksh
run: sudo apt-get update -qq && sudo apt-get install -y -qq mksh
- name: mksh -n (shell d'Android)
run: |
for f in $MODULE_SCRIPTS; do
echo "mksh -n $f"
mksh -n "$f"
done
- name: bash -n build.sh
run: bash -n build.sh

hygiene:
name: Fichiers (CRLF, BOM, shebang)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pas de CRLF ni de BOM dans les fichiers du module
run: |
fail=0
for f in $MODULE_SCRIPTS module.prop system.prop META-INF/com/google/android/updater-script; do
if grep -q $'\r' "$f"; then echo "::error file=$f::fins de ligne CRLF (Android exige LF)"; fail=1; fi
if [ "$(head -c3 "$f" | xxd -p)" = "efbbbf" ]; then echo "::error file=$f::BOM UTF-8 présent"; fail=1; fi
done
exit $fail
- name: Shebang présent
run: |
fail=0
for f in $MODULE_SCRIPTS; do
case "$(head -n1 "$f")" in
'#!'*) ;;
*) echo "::error file=$f::shebang manquant"; fail=1 ;;
esac
done
exit $fail
- name: updater-script contient #MAGISK
run: grep -qx '#MAGISK' META-INF/com/google/android/updater-script

metadata:
name: Métadonnées et versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: module.prop valide
run: |
fail=0
for key in id name version versionCode author description; do
grep -q "^${key}=." module.prop || { echo "::error file=module.prop::champ '$key' manquant ou vide"; fail=1; }
done
grep -Eq '^versionCode=[0-9]+$' module.prop || { echo "::error file=module.prop::versionCode doit être un entier"; fail=1; }
grep -Eq '^version=[0-9]+\.[0-9]+\.[0-9]+$' module.prop || { echo "::error file=module.prop::version doit être de la forme X.Y.Z"; fail=1; }
exit $fail
- name: Cohérence des versions (module.prop, service.sh, caros_config.sh)
run: |
V=$(sed -n 's/^version=//p' module.prop | tr -d '\r')
S=$(sed -n 's/.*CarOS Profile Switcher service v\([0-9][0-9.]*\).*/\1/p' service.sh | head -n1)
C=$(sed -n 's/.*Centralized Configuration v\([0-9][0-9.]*\).*/\1/p' caros_config.sh | head -n1)
echo "module.prop=$V service.sh=$S caros_config.sh=$C"
if [ "$V" != "$S" ] || [ "$V" != "$C" ]; then
echo "::error::versions incohérentes"; exit 1
fi
- name: CHANGELOG contient la version courante
run: |
V=$(sed -n 's/^version=//p' module.prop)
grep -q "^## \[$V\]" CHANGELOG.md || { echo "::error file=CHANGELOG.md::pas de section '## [$V]'"; exit 1; }

actionlint:
name: Lint des workflows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: actionlint
run: |
bash <(curl -fsSL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.7/scripts/download-actionlint.bash) 1.7.7
./actionlint -color

build:
name: Build du ZIP Magisk
runs-on: ubuntu-latest
needs: [ shellcheck, syntax, hygiene, metadata ]
steps:
- uses: actions/checkout@v4
- name: Build (build.sh)
run: bash build.sh
- name: Vérifier le contenu du ZIP
run: |
ZIP=$(ls rel/CarOS_Profile_Switcher-v*.zip)
unzip -Z1 "$ZIP" | sort > actual.txt
cat > expected.txt <<'LIST'
META-INF/
META-INF/com/
META-INF/com/google/
META-INF/com/google/android/
META-INF/com/google/android/update-binary
META-INF/com/google/android/updater-script
caros_config.sh
grant_permissions.sh
module.prop
post-fs-data.sh
service.sh
system.prop
LIST
sort -o expected.txt expected.txt
diff expected.txt actual.txt && echo "Contenu du ZIP conforme"
unzip -tq "$ZIP"
- name: Publier le ZIP (artefact)
uses: actions/upload-artifact@v4
with:
name: caros-profile-switcher-${{ github.sha }}
path: rel/*.zip
retention-days: 14
if-no-files-found: error
142 changes: 58 additions & 84 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,71 @@
name: Build and Release
name: Release

on:
push:
tags:
- 'v*.*.*' # Triggers on version tags like v0.2.4
workflow_dispatch: # Allows manual trigger
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write
contents: read

jobs:
build:
ci:
name: CI
uses: ./.github/workflows/ci.yml

release:
name: Publier la release
needs: ci
runs-on: ubuntu-latest

permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Extract version from tag
id: get_version
run: |
if [ "${{ github.ref_type }}" == "tag" ]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION=$(grep "^version=" module.prop | cut -d'=' -f2)
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"

- name: Validate required files
run: |
echo "Checking required files..."
for file in caros_config.sh module.prop post-fs-data.sh service.sh system.prop grant_permissions.sh META-INF/com/google/android/update-binary META-INF/com/google/android/updater-script; do
if [ ! -f "$file" ]; then
echo "Error: Missing required file: $file"
- uses: actions/checkout@v4

- name: Le tag correspond à module.prop
id: ver
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PROP_VERSION=$(sed -n 's/^version=//p' module.prop | tr -d '\r')
if [ "$TAG_VERSION" != "$PROP_VERSION" ]; then
echo "::error::tag $GITHUB_REF_NAME != version=$PROP_VERSION dans module.prop"
exit 1
fi
done
echo "All required files present ✓"

- name: Create release directory
run: mkdir -p rel

- name: Build release ZIP
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
OUTPUT_FILE="rel/CarOS_Profile_Switcher-v${VERSION}.zip"

zip -r "$OUTPUT_FILE" \
caros_config.sh \
module.prop \
post-fs-data.sh \
service.sh \
system.prop \
grant_permissions.sh \
META-INF

echo "Created: $OUTPUT_FILE"
ls -lh "$OUTPUT_FILE"

- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: rel/*.zip
body: |
## CarOS Profile Switcher v${{ steps.get_version.outputs.VERSION }}

echo "version=$PROP_VERSION" >> "$GITHUB_OUTPUT"

- name: Build (build.sh)
run: bash build.sh "${{ steps.ver.outputs.version }}"

- name: Notes de release (extraites de CHANGELOG.md)
env:
VERSION: ${{ steps.ver.outputs.version }}
REPO: ${{ github.repository }}
run: |
{
echo "## CarOS Profile Switcher v${VERSION}"
echo
awk -v v="$VERSION" '
$0 ~ "^## \\[" v "\\]" { on=1; next }
on && /^## \[/ { exit }
on { print }
' CHANGELOG.md
cat <<EOT

### Installation
1. Download the ZIP file below
2. Open Magisk Manager
3. Go to Modules → Install from storage
4. Select the downloaded ZIP
5. Reboot

### Configuration
Edit `/sdcard/CarOS/config.env` after installation.

See [EXAMPLES.md](https://github.com/${{ github.repository }}/blob/main/EXAMPLES.md) for car-specific configurations.

### Changelog
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.

---
**Requirements**: Magisk v20.4+, Android Auto, Root access
draft: false
prerelease: false

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: caros-profile-switcher-v${{ steps.get_version.outputs.VERSION }}
path: rel/*.zip
retention-days: 90
1. Télécharger le ZIP ci-dessous
2. Magisk → Modules → Installer depuis le stockage
3. Choisir le ZIP puis redémarrer

Configuration : \`/sdcard/CarOS/config.env\` (voir [EXAMPLES.md](https://github.com/${REPO}/blob/main/EXAMPLES.md)).

**Prérequis** : Magisk v20.4+, Android Auto, accès root.
EOT
} > release-notes.md
cat release-notes.md

- name: Créer la release GitHub
uses: softprops/action-gh-release@v2
with:
files: rel/*.zip
body_path: release-notes.md
fail_on_unmatched_files: true
Loading
Loading