Build Magisk Module Zip #116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Magisk Module Zip | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Trigger on version tags, e.g., v1.0.2 | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Versioni i ri i modulës' | |
required: false | |
default: '1.0.0' | |
type: string | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout repository me historikun e plotë | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Sigurohuni që të keni akses në historikun e plotë të git për të push-uar ndryshimet | |
# 2. Vendosja e variablit të versionit | |
- name: Set version environment variable | |
id: set_version | |
run: | | |
if [ "${{ github.event_name }}" = "push" ]; then | |
VERSION=${{ github.event.ref }} | |
VERSION=${VERSION#refs/tags/} # Heq prefiksin refs/tags/ nga tag-u | |
VERSION=${VERSION#v} # Heq 'v' nga fillimi | |
else | |
VERSION=${{ github.event.inputs.version }} | |
fi | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
# 3. Shfaq versionin për verifikim | |
- name: Display Version | |
run: echo "Building version ${{ env.VERSION }}" | |
# 6. Rrit versionCode automatikisht me 1 në update.json dhe përditëso versionin dhe zipUrl | |
- name: Update versionCode, version, and zipUrl in update.json | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
# Lexo versionCode aktual nga update.json | |
current_version_code=$(jq -r '.versionCode' update.json) | |
# Rrit versionCode me 1 | |
new_version_code=$((current_version_code + 1)) | |
# Përditësoj versionCode, version, dhe zipUrl në update.json | |
jq --arg version "${{ env.VERSION }}" \ | |
--arg zipUrl "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/Boot_Scripts_${{ env.VERSION }}.zip" \ | |
--argjson versionCode "$new_version_code" \ | |
'.version = $version | .zipUrl = $zipUrl | .versionCode = $versionCode' \ | |
update.json > tmp.json && mv tmp.json update.json | |
echo "Updated update.json with versionCode $new_version_code, version ${{ env.VERSION }} and zipUrl" | |
# 5. Commit dhe push ndryshimet në update.json | |
- name: Commit dhe push ndryshimet në update.json | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Përditësoj update.json me versionin ${{ env.VERSION }}" | |
branch: cocka11 # Emri i duhur i degës | |
file_pattern: update.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 3. Rrit versionCode automatikisht me 1 | |
- name: Increment versionCode in module.prop | |
run: | | |
# Lexo versionCode aktual nga module.prop | |
current_version_code=$(grep '^versionCode=' module.prop | cut -d'=' -f2) | |
# Rrit versionCode me 1 | |
new_version_code=$((current_version_code + 1)) | |
# Përditëso versionCode në module.prop | |
sed -i "s/^versionCode=.*/versionCode=${new_version_code}/" module.prop | |
echo "Updated module.prop with versionCode $new_version_code" | |
echo "VERSION_CODE=${new_version_code}" >> $GITHUB_ENV | |
# 6. Përdor sed për të përditësuar versionin në module.prop | |
- name: Update version in module.prop | |
run: | | |
sed -i "s/^version=.*/version=${{ env.VERSION }}/" module.prop | |
# 7. Commit dhe push ndryshimet në module.prop | |
- name: Commit dhe push ndryshimet në module.prop | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Përditësoj module.prop me versionin ${{ env.VERSION }}" | |
branch: cocka11 # Emri i duhur i degës | |
file_pattern: module.prop | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 8. Krijo skedarin ZIP me emër versioni | |
- name: Create zip archive | |
run: | | |
ZIP_NAME="Boot_Scripts_${{ env.VERSION }}.zip" | |
echo "Creating ZIP: $ZIP_NAME" | |
zip -r $ZIP_NAME ./* -x '.git/*' '.github/*' | |
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV | |
# 9. Krijo Release dhe Ngarko ZIP-in | |
- name: Create Release and Upload Zip | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ env.VERSION }} | |
name: Release v${{ env.VERSION }} | |
files: | | |
Boot_Scripts_${{ env.VERSION }}.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 10. Kontrollo Statusin e Ngarkimit | |
- name: Check Upload Status | |
run: | | |
echo "Verifikoni nëse ZIP u ngarkua me sukses në release." | |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.VERSION }} |