Skip to content

Commit

Permalink
Create build-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
fam007e authored Sep 24, 2024
1 parent 35e3bba commit ebd1145
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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 srt_tr.py
- name: Build Linux binary with PyInstaller
run: |
pyinstaller --onefile --name srt_tr_linux srt_tr.py
- 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

0 comments on commit ebd1145

Please sign in to comment.