Creează lansare de tip draft #2
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: Creează lansare de tip draft | |
on: | |
workflow_dispatch: # Permite rularea manuală a workflow-ului cu parametri | |
inputs: | |
increment_type: | |
description: "Tipul de incrementare al versiunii (major/minor/patch)" | |
required: true | |
default: "patch" # Implicit se incrementează PATCH | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
release: | |
name: Creează Lansare de tip draft | |
runs-on: ubuntu-22.04 # Ubuntu 22.04 este stabil și suportă Python 3.10 | |
steps: | |
# 1. Checkout repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# 2. Set up Python (versiune compatibilă) | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' # Versiune stabilă și compatibilă | |
# 3. Update manifest.json version | |
- name: Update manifest.json version | |
id: update_manifest | |
run: | | |
# Verifică dacă jq este instalat | |
if ! command -v jq &> /dev/null; then | |
echo "Installing jq..." | |
sudo apt-get update && sudo apt-get install -y jq | |
fi | |
# Definim calea către manifest.json | |
MANIFEST_PATH="custom_components/eonromania/manifest.json" | |
# Verificăm dacă fișierul există | |
if [ ! -f "$MANIFEST_PATH" ]; then | |
echo "Error: manifest.json not found at $MANIFEST_PATH" | |
exit 1 | |
fi | |
# Citește versiunea actuală | |
VERSION=$(jq -r '.version' "$MANIFEST_PATH") | |
echo "Current version: $VERSION" | |
# Sparge versiunea în MAJOR, MINOR și PATCH | |
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
# Verificăm tipul de incrementare | |
INCREMENT_TYPE="${{ github.event.inputs.increment_type }}" | |
echo "Increment type: $INCREMENT_TYPE" | |
if [ "$INCREMENT_TYPE" = "major" ]; then | |
MAJOR=$((MAJOR + 1)) | |
MINOR=0 | |
PATCH=0 | |
elif [ "$INCREMENT_TYPE" = "minor" ]; then | |
MINOR=$((MINOR + 1)) | |
PATCH=0 | |
elif [ "$INCREMENT_TYPE" = "patch" ]; then | |
PATCH=$((PATCH + 1)) | |
else | |
echo "Invalid increment type: $INCREMENT_TYPE. Use 'major', 'minor', or 'patch'." | |
exit 1 | |
fi | |
# Creează noua versiune | |
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
echo "New version: $NEW_VERSION" | |
# Actualizează manifest.json | |
jq --arg version "$NEW_VERSION" '.version = $version' "$MANIFEST_PATH" > manifest.tmp && mv manifest.tmp "$MANIFEST_PATH" | |
# Setează noua versiune ca variabilă de mediu | |
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV | |
# 4. Commit și push modificările folosind PAT | |
- name: Commit changes and push | |
env: | |
PAT: ${{ secrets.PAT_TOKEN }} # Token-ul salvat ca secret | |
run: | | |
# Configurare GitHub Actions bot | |
git config user.name "eonromania-release-bot" | |
git config user.email "[email protected]" | |
# Setează URL-ul remote pentru autentificare cu token | |
git remote set-url origin https://x-access-token:${PAT}@github.com/cnecrea/eonromania.git | |
# Adaugă și face commit la modificări | |
git add custom_components/eonromania/manifest.json | |
git commit -m "Update version to ${{ env.new_version }}" | |
# Push la modificări | |
git push origin HEAD | |
# 5. Creează un fișier .zip doar cu conținutul folderului eonromania | |
- name: Create ZIP Archive | |
run: | | |
mkdir -p dist | |
cd custom_components/eonromania | |
zip -r ../../dist/eonromania.zip ./* | |
# 6. Creează un release pe GitHub ca draft | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: "${{ env.new_version }}" # Creează un tag | |
name: "${{ env.new_version }}" # Nume pentru release | |
body: | | |
## Lansare de tip draft | |
- Această lansare a fost generată automat de GitHub Actions. | |
- Verificați conținutul înainte de publicare. | |
files: dist/eonromania.zip # Include fișierul ZIP în release | |
draft: true # Creează release-ul ca draft | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Token-ul implicit GitHub |