Skip to content

Commit 5bab4d5

Browse files
authored
Merge pull request #7 from cancel-cloud/copilot/fix-6
Implement automatic versioning and GitHub releases system
2 parents e52b344 + 8c998d9 commit 5bab4d5

6 files changed

Lines changed: 200 additions & 2 deletions

File tree

File renamed without changes.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Auto Version and Release
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
types: [ closed ]
8+
branches: [ "main" ]
9+
10+
jobs:
11+
version-and-release:
12+
if: github.event_name == 'push' || (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main')
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Get current version
31+
id: current_version
32+
run: |
33+
VERSION=$(python3 -c "from version import get_version; print(get_version())")
34+
echo "current_version=$VERSION" >> $GITHUB_OUTPUT
35+
echo "Current version: $VERSION"
36+
37+
- name: Increment version
38+
id: new_version
39+
run: |
40+
# Get the current version and increment patch number
41+
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
42+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
43+
MAJOR=${VERSION_PARTS[0]}
44+
MINOR=${VERSION_PARTS[1]}
45+
PATCH=${VERSION_PARTS[2]}
46+
NEW_PATCH=$((PATCH + 1))
47+
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
48+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
49+
echo "New version: $NEW_VERSION"
50+
51+
- name: Update version in code
52+
run: |
53+
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
54+
sed -i "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" version.py
55+
echo "Updated version.py with version $NEW_VERSION"
56+
57+
- name: Generate changelog
58+
id: changelog
59+
run: |
60+
# Get the latest tag
61+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
62+
if [ -z "$LATEST_TAG" ]; then
63+
echo "No previous tag found, getting all commits"
64+
COMMITS=$(git log --oneline --pretty=format:"- %s" HEAD)
65+
else
66+
echo "Getting commits since $LATEST_TAG"
67+
COMMITS=$(git log --oneline --pretty=format:"- %s" $LATEST_TAG..HEAD)
68+
fi
69+
70+
# Create changelog
71+
{
72+
echo "## Changes in v${{ steps.new_version.outputs.new_version }}"
73+
echo ""
74+
if [ -n "$COMMITS" ]; then
75+
echo "$COMMITS"
76+
else
77+
echo "- Minor updates and improvements"
78+
fi
79+
} > CHANGELOG.md
80+
81+
# Set output for release notes
82+
{
83+
echo 'changelog<<EOF'
84+
cat CHANGELOG.md
85+
echo EOF
86+
} >> $GITHUB_OUTPUT
87+
88+
- name: Commit version update
89+
run: |
90+
git config --local user.email "action@github.com"
91+
git config --local user.name "GitHub Action"
92+
git add version.py
93+
git commit -m "Bump version to v${{ steps.new_version.outputs.new_version }}" || echo "No changes to commit"
94+
git push
95+
96+
- name: Create Git Tag
97+
run: |
98+
git tag "v${{ steps.new_version.outputs.new_version }}"
99+
git push origin "v${{ steps.new_version.outputs.new_version }}"
100+
101+
- name: Create GitHub Release
102+
uses: ncipollo/release-action@v1
103+
with:
104+
tag: v${{ steps.new_version.outputs.new_version }}
105+
name: Release v${{ steps.new_version.outputs.new_version }}
106+
body: ${{ steps.changelog.outputs.changelog }}
107+
draft: false
108+
prerelease: false
109+
token: ${{ secrets.GITHUB_TOKEN }}
110+
111+
- name: Log in to the GitHub Container Registry
112+
uses: docker/login-action@v3
113+
with:
114+
registry: ghcr.io
115+
username: ${{ github.actor }}
116+
password: ${{ secrets.GITHUB_TOKEN }}
117+
118+
- name: Extract metadata (tags, labels) for Docker
119+
id: meta
120+
uses: docker/metadata-action@v5
121+
with:
122+
images: ghcr.io/${{ github.repository }}
123+
tags: |
124+
type=raw,value=latest
125+
type=raw,value=v${{ steps.new_version.outputs.new_version }}
126+
127+
- name: Build and push Docker image
128+
uses: docker/build-push-action@v5
129+
with:
130+
context: .
131+
push: true
132+
tags: ${{ steps.meta.outputs.tags }}
133+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
.DS_Store
2+
3+
# Python
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Dein persönlicher Assistent, der nie schläft! Dieses Tool meldet sich täglich
66
<img src="https://img.shields.io/github/downloads/cancel-cloud/IdleOutpostClaimer/total?logo=github&style=for-the-badge&label=Forks" alt="GitHub Forks"/>
77
<img src="https://img.shields.io/github/license/cancel-cloud/IdleOutpostClaimer?style=for-the-badge" alt="License"/>
88
<img src="https://img.shields.io/github/last-commit/cancel-cloud/IdleOutpostClaimer?style=for-the-badge&logo=github" alt="Last Commit"/>
9+
<img src="https://img.shields.io/github/v/release/cancel-cloud/IdleOutpostClaimer?style=for-the-badge" alt="Latest Release"/>
910
</div>
1011

1112
---
@@ -30,6 +31,33 @@ Sind wir ehrlich: Tägliche Anmeldeboni sind super, aber man vergisst sie leicht
3031
- **📦 Docker-isoliert**: Läuft in einem sauberen, abgeschotteten Container. "Set it and forget it!"
3132
- **⚙️ Minimale Konfiguration**: Alles, was du brauchst, ist deine `USER_GAME_ID`.
3233
- **📝 Detailliertes Logging**: Jede Aktion wird protokolliert. Du hast volle Kontrolle und Transparenz.
34+
- **🔄 Automatische Versionierung**: Das System erstellt automatisch neue Releases und aktualisiert Versionsnummern bei jeder Aktualisierung.
35+
- **📊 Versionsverfolgung**: Jeder Log-Eintrag zeigt die aktuelle Version an, sodass du immer weißt, welche Version läuft.
36+
37+
---
38+
39+
## 📋 Versionierung & Releases
40+
41+
Das Projekt verwendet ein automatisches Versionierungssystem:
42+
43+
- **🏷️ Automatische Releases**: Bei jedem Push oder Merge in den `main`-Branch wird automatisch eine neue Version erstellt
44+
- **📈 Patch-Versionierung**: Versionen werden automatisch hochgezählt (z.B. 1.0.4 → 1.0.5 → 1.0.6)
45+
- **📝 Changelog**: Jedes Release enthält eine Liste der Änderungen seit der letzten Version
46+
- **🐳 Docker Tags**: Docker Images werden automatisch mit der aktuellen Versionsnummer getaggt
47+
- **📊 Logs mit Version**: Die Anwendung zeigt die aktuelle Version in allen Log-Ausgaben an
48+
49+
### Aktuelle Version anzeigen
50+
51+
Die aktuelle Version wird beim Start der Anwendung angezeigt:
52+
```
53+
[22.07.25-20:37] 🚀 Idle Outpost Claimer v1.0.4 gestartet.
54+
[22.07.25-20:37] ⚙️ Idle Outpost Claimer v1.0.4 - Führe planmäßigen Claim aus...
55+
```
56+
57+
Du kannst auch die Version direkt abfragen:
58+
```bash
59+
docker exec idle-outpost-claimer python3 -c "from version import get_version; print(f'Version: {get_version()}')"
60+
```
3361

3462
---
3563

app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from datetime import datetime, timedelta
55
import sys
66
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
7+
from version import get_version
78

89

910
# Basis-URLs
@@ -103,7 +104,7 @@ def show_startup_message():
103104
hours, remainder = divmod(time_diff.seconds, 3600)
104105
minutes, _ = divmod(remainder, 60)
105106

106-
log("🚀 Idle Outpost Claimer gestartet.")
107+
log(f"🚀 Idle Outpost Claimer v{get_version()} gestartet.")
107108
log(f"Nächster automatischer Claim um {next_run.strftime('%H:%M')}. Das ist in {hours} Stunden und {minutes} Minuten.")
108109

109110

@@ -129,4 +130,4 @@ def show_startup_message():
129130
claim(sess, 'legendary')
130131
claim(sess, 'weekly')
131132

132-
log("\n🏁 Alle Aktionen abgeschlossen.")
133+
log("\n🏁 Alle Aktionen abgeschlossen.")

version.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Version management for IdleOutpostClaimer
4+
"""
5+
6+
# Current version of the application
7+
__version__ = "1.0.4"
8+
9+
def get_version():
10+
"""
11+
Get the current version string
12+
13+
Returns:
14+
str: Current version number
15+
"""
16+
return __version__
17+
18+
def get_version_info():
19+
"""
20+
Get detailed version information
21+
22+
Returns:
23+
dict: Version information including major, minor, and patch numbers
24+
"""
25+
parts = __version__.split('.')
26+
return {
27+
'major': int(parts[0]) if len(parts) > 0 else 0,
28+
'minor': int(parts[1]) if len(parts) > 1 else 0,
29+
'patch': int(parts[2]) if len(parts) > 2 else 0,
30+
'version_string': __version__
31+
}

0 commit comments

Comments
 (0)