diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml.backup similarity index 100% rename from .github/workflows/docker-publish.yml rename to .github/workflows/docker-publish.yml.backup diff --git a/.github/workflows/version-and-release.yml b/.github/workflows/version-and-release.yml new file mode 100644 index 0000000..8fb0759 --- /dev/null +++ b/.github/workflows/version-and-release.yml @@ -0,0 +1,133 @@ +name: Auto Version and Release + +on: + push: + branches: [ "main" ] + pull_request: + types: [ closed ] + branches: [ "main" ] + +jobs: + version-and-release: + if: github.event_name == 'push' || (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main') + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Get current version + id: current_version + run: | + VERSION=$(python3 -c "from version import get_version; print(get_version())") + echo "current_version=$VERSION" >> $GITHUB_OUTPUT + echo "Current version: $VERSION" + + - name: Increment version + id: new_version + run: | + # Get the current version and increment patch number + CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + MAJOR=${VERSION_PARTS[0]} + MINOR=${VERSION_PARTS[1]} + PATCH=${VERSION_PARTS[2]} + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "New version: $NEW_VERSION" + + - name: Update version in code + run: | + NEW_VERSION="${{ steps.new_version.outputs.new_version }}" + sed -i "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" version.py + echo "Updated version.py with version $NEW_VERSION" + + - name: Generate changelog + id: changelog + run: | + # Get the latest tag + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -z "$LATEST_TAG" ]; then + echo "No previous tag found, getting all commits" + COMMITS=$(git log --oneline --pretty=format:"- %s" HEAD) + else + echo "Getting commits since $LATEST_TAG" + COMMITS=$(git log --oneline --pretty=format:"- %s" $LATEST_TAG..HEAD) + fi + + # Create changelog + { + echo "## Changes in v${{ steps.new_version.outputs.new_version }}" + echo "" + if [ -n "$COMMITS" ]; then + echo "$COMMITS" + else + echo "- Minor updates and improvements" + fi + } > CHANGELOG.md + + # Set output for release notes + { + echo 'changelog<> $GITHUB_OUTPUT + + - name: Commit version update + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add version.py + git commit -m "Bump version to v${{ steps.new_version.outputs.new_version }}" || echo "No changes to commit" + git push + + - name: Create Git Tag + run: | + git tag "v${{ steps.new_version.outputs.new_version }}" + git push origin "v${{ steps.new_version.outputs.new_version }}" + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + tag: v${{ steps.new_version.outputs.new_version }} + name: Release v${{ steps.new_version.outputs.new_version }} + body: ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to the GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest + type=raw,value=v${{ steps.new_version.outputs.new_version }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index e43b0f9..eb1a52c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ .DS_Store + +# Python +__pycache__/ +*.py[cod] +*$py.class diff --git a/README.md b/README.md index 1eefa8f..bb1c1cd 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Dein persönlicher Assistent, der nie schläft! Dieses Tool meldet sich täglich GitHub Forks License Last Commit + Latest Release --- @@ -30,6 +31,33 @@ Sind wir ehrlich: Tägliche Anmeldeboni sind super, aber man vergisst sie leicht - **📦 Docker-isoliert**: Läuft in einem sauberen, abgeschotteten Container. "Set it and forget it!" - **⚙️ Minimale Konfiguration**: Alles, was du brauchst, ist deine `USER_GAME_ID`. - **📝 Detailliertes Logging**: Jede Aktion wird protokolliert. Du hast volle Kontrolle und Transparenz. +- **🔄 Automatische Versionierung**: Das System erstellt automatisch neue Releases und aktualisiert Versionsnummern bei jeder Aktualisierung. +- **📊 Versionsverfolgung**: Jeder Log-Eintrag zeigt die aktuelle Version an, sodass du immer weißt, welche Version läuft. + +--- + +## 📋 Versionierung & Releases + +Das Projekt verwendet ein automatisches Versionierungssystem: + +- **🏷️ Automatische Releases**: Bei jedem Push oder Merge in den `main`-Branch wird automatisch eine neue Version erstellt +- **📈 Patch-Versionierung**: Versionen werden automatisch hochgezählt (z.B. 1.0.4 → 1.0.5 → 1.0.6) +- **📝 Changelog**: Jedes Release enthält eine Liste der Änderungen seit der letzten Version +- **🐳 Docker Tags**: Docker Images werden automatisch mit der aktuellen Versionsnummer getaggt +- **📊 Logs mit Version**: Die Anwendung zeigt die aktuelle Version in allen Log-Ausgaben an + +### Aktuelle Version anzeigen + +Die aktuelle Version wird beim Start der Anwendung angezeigt: +``` +[22.07.25-20:37] 🚀 Idle Outpost Claimer v1.0.4 gestartet. +[22.07.25-20:37] ⚙️ Idle Outpost Claimer v1.0.4 - Führe planmäßigen Claim aus... +``` + +Du kannst auch die Version direkt abfragen: +```bash +docker exec idle-outpost-claimer python3 -c "from version import get_version; print(f'Version: {get_version()}')" +``` --- diff --git a/app.py b/app.py index 84a62a3..ab1fb12 100644 --- a/app.py +++ b/app.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta import sys from zoneinfo import ZoneInfo, ZoneInfoNotFoundError +from version import get_version # Basis-URLs @@ -103,7 +104,7 @@ def show_startup_message(): hours, remainder = divmod(time_diff.seconds, 3600) minutes, _ = divmod(remainder, 60) - log("🚀 Idle Outpost Claimer gestartet.") + log(f"🚀 Idle Outpost Claimer v{get_version()} gestartet.") log(f"Nächster automatischer Claim um {next_run.strftime('%H:%M')}. Das ist in {hours} Stunden und {minutes} Minuten.") @@ -129,4 +130,4 @@ def show_startup_message(): claim(sess, 'legendary') claim(sess, 'weekly') - log("\n🏁 Alle Aktionen abgeschlossen.") \ No newline at end of file + log("\n🏁 Alle Aktionen abgeschlossen.") diff --git a/version.py b/version.py new file mode 100644 index 0000000..85bba57 --- /dev/null +++ b/version.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +""" +Version management for IdleOutpostClaimer +""" + +# Current version of the application +__version__ = "1.0.4" + +def get_version(): + """ + Get the current version string + + Returns: + str: Current version number + """ + return __version__ + +def get_version_info(): + """ + Get detailed version information + + Returns: + dict: Version information including major, minor, and patch numbers + """ + parts = __version__.split('.') + return { + 'major': int(parts[0]) if len(parts) > 0 else 0, + 'minor': int(parts[1]) if len(parts) > 1 else 0, + 'patch': int(parts[2]) if len(parts) > 2 else 0, + 'version_string': __version__ + } \ No newline at end of file