Skip to content

v.1.2.8

v.1.2.8 #15

Workflow file for this run

name: Create Tag and Release on Version Change
on:
push:
paths:
- usr/lib/enigma2/python/Plugins/Extensions/Foreca1/__init__.py
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
tag_and_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read version from file
id: get_version
run: |
VERSION=$(grep -oP '(?<=__version__ = ")[^"]+' usr/lib/enigma2/python/Plugins/Extensions/Foreca1/__init__.py)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if tag already exists
id: check_tag
run: |
if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.get_version.outputs.version }}$"; then
echo "Tag v${{ steps.get_version.outputs.version }} already exists."
echo "skip=true" >> $GITHUB_OUTPUT
exit 0
fi
- name: Create and push tag
if: steps.check_tag.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag v${{ steps.get_version.outputs.version }}
git push origin v${{ steps.get_version.outputs.version }}
- name: Generate changelog
id: changelog
if: steps.check_tag.outputs.skip != 'true'
run: |
LAST_TAG=$(git describe --tags --abbrev=0 --exclude "v${{ steps.get_version.outputs.version }}" 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
echo "No previous tag found, showing last 10 commits."
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -n 10)
else
echo "Previous tag: $LAST_TAG"
CHANGELOG=$(git log "$LAST_TAG"..HEAD --pretty=format:"- %s (%h)" --no-merges -n 10)
fi
# Escape only % to avoid GitHub Actions output issues
CHANGELOG="${CHANGELOG//'%'/'%25'}"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
if: steps.check_tag.outputs.skip != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
body: |
## Changes in this release
${{ steps.changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}