Skip to content

Update srt_tr.py

Update srt_tr.py #4

Workflow file for this run

name: Build and Release SRT Translator
on:
push:
branches:
- main
paths:
- srt_tr.py
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller deep-translator tqdm
- name: Build Windows executable with PyInstaller
run: |
pyinstaller --onefile --name srt_tr_win.exe srt_tr.py
- name: Build Linux binary with PyInstaller
run: |
pyinstaller --onefile --name srt_tr_linux srt_tr.py
- name: List dist directory contents
run: ls -l dist
- name: Get previous release version
id: get_release
run: |
VERSION_PREFIX=$(date +'%Y.%m.%d')
RELEASES=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases)
COUNT=$(echo "$RELEASES" | jq '. | length')
if [ "$COUNT" -eq "0" ]; then
VERSION="${VERSION_PREFIX}.1"
else
PREV_VERSION=$(echo "$RELEASES" | jq -r '.[0].tag_name')
PREV_VERSION_NUM=$(echo "$PREV_VERSION" | awk -F '.' '{print $4}')
NEXT_VERSION_NUM=$((PREV_VERSION_NUM+1))
VERSION="${VERSION_PREFIX}.${NEXT_VERSION_NUM}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Generate changelog
id: generate_changelog
run: |
echo "## Changelog for version ${{ env.VERSION }}" > changelog.md
echo "" >> changelog.md
git log -1 --pretty=format:"%h - %s (%an)" >> changelog.md
echo "" >> changelog.md
echo "For a full list of changes, refer to the commit history." >> changelog.md
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.VERSION }}
release_name: "SRT Translator ${{ env.VERSION }}"
body_path: changelog.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.SRT_TR_TOKEN }}
- name: Upload Windows executable to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/srt_tr_win.exe
asset_name: srt_tr_win_${{ env.VERSION }}.exe
asset_content_type: application/octet-stream
- name: Upload Linux binary to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/srt_tr_linux
asset_name: srt_tr_linux_${{ env.VERSION }}
asset_content_type: application/octet-stream