Skip to content

Commit e1474ff

Browse files
committed
add autotag
add ruff
1 parent 8451155 commit e1474ff

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

.github/workflows/ruff.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Ruff Linter
2+
3+
on:
4+
push:
5+
branches:
6+
- python3
7+
pull_request:
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install Ruff
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install ruff
26+
27+
- name: Run Ruff
28+
run: |
29+
cd src
30+
ruff check .

.github/workflows/tag_release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Create Tag and Release on Version Change
2+
3+
on:
4+
push:
5+
paths:
6+
- src/__init__.py
7+
branches:
8+
- python3
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
tag_and_release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Read version from file
23+
id: get_version
24+
run: |
25+
VERSION=$(grep -oP '(?<=__version__ = ")[^"]+' src/__init__.py)
26+
echo "version=$VERSION" >> $GITHUB_OUTPUT
27+
28+
- name: Check if tag already exists
29+
id: check_tag
30+
run: |
31+
if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.get_version.outputs.version }}$"; then
32+
echo "Tag v${{ steps.get_version.outputs.version }} already exists."
33+
echo "skip=true" >> $GITHUB_OUTPUT
34+
exit 0
35+
fi
36+
37+
- name: Create and push tag
38+
if: steps.check_tag.outputs.skip != 'true'
39+
run: |
40+
git config user.name "github-actions[bot]"
41+
git config user.email "github-actions[bot]@users.noreply.github.com"
42+
git tag v${{ steps.get_version.outputs.version }}
43+
git push origin v${{ steps.get_version.outputs.version }}
44+
45+
- name: Generate changelog
46+
id: changelog
47+
if: steps.check_tag.outputs.skip != 'true'
48+
run: |
49+
LAST_TAG=$(git describe --tags --abbrev=0 --exclude "v${{ steps.get_version.outputs.version }}" 2>/dev/null || echo "")
50+
51+
if [ -z "$LAST_TAG" ]; then
52+
echo "No previous tag found, showing last 10 commits."
53+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -n 10)
54+
else
55+
echo "Previous tag: $LAST_TAG"
56+
CHANGELOG=$(git log "$LAST_TAG"..HEAD --pretty=format:"- %s (%h)" --no-merges -n 10)
57+
fi
58+
59+
# Escape only % to avoid GitHub Actions output issues
60+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
61+
62+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
63+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
64+
echo "EOF" >> $GITHUB_OUTPUT
65+
66+
- name: Create GitHub Release
67+
if: steps.check_tag.outputs.skip != 'true'
68+
uses: softprops/action-gh-release@v2
69+
with:
70+
tag_name: v${{ steps.get_version.outputs.version }}
71+
name: Release v${{ steps.get_version.outputs.version }}
72+
body: |
73+
## Changes in this release
74+
${{ steps.changelog.outputs.changelog }}
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
PLUGINPATH = resolveFilename(SCOPE_PLUGINS, "Extensions/OpenATVstatus/")
1010

11+
__version__ = "2.7"
12+
1113

1214
def localeInit():
1315
bindtextdomain("OpenATVstatus", join(PLUGINPATH, "locale"))

0 commit comments

Comments
 (0)