-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |