Skip to content

Commit

Permalink
feat: add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Nov 14, 2024
1 parent b79838c commit 0c963bb
Showing 1 changed file with 69 additions and 15 deletions.
84 changes: 69 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
name: Build ffsubsync Executables
name: Build

on:
workflow_dispatch:
push:
branches:
- master
workflow_dispatch:
push:
branches:
- master
tags:
- v*

env:
DIST_DIR: /tmp/builds

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
build: win-x64
file_name: win_amd64
- os: ubuntu-latest
build: linux-x64
file_name: linux_amd64
- os: macos-latest
build: osx-arm64
file_name: macos_arm64

runs-on: ${{ matrix.os }}

steps:
- name: Check out the repository
Expand All @@ -23,15 +38,15 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip'
cache: "pip"

- run: pip install -r requirements.txt

- if: matrix.os != 'macos-latest'
name: Install UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
install-only: true

- name: Download ffmpeg
run: python ffmpeg_download.py
Expand All @@ -47,9 +62,48 @@ jobs:
run: pyinstaller --clean -y --dist ./dist/ffsubsync_bin *.spec
shell: bash

- name: Archive the build
- name: Move to DIST_DIR
run: mv dist/ffsubsync_bin $DIST_DIR/ffsubsync_bin-${{ matrix.file_name }}
shell: bash

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ffsubsync_bin-${{ matrix.os }}
path: |
dist/ffsubsync_bin
name: build-${{ matrix.file_name }}
path: ${{ env.DIST_DIR }}/*
if-no-files-found: error
retention-days: 1

release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
steps:
- name: Download builds
uses: actions/download-artifact@v4
with:
path: ${{ env.DIST_DIR }}
pattern: build-*
merge-multiple: true

# checksums.txt
- name: Calculate checksums.txt
run: |
cd $DIST_DIR
sha256sum * > checksums.txt
# print checksums.txt
cat checksums.txt
FILES=$(find ${DIST_DIR} -type f -exec readlink -f {} \;)
echo -e "RELEASE_FILES<<EOF" >> $GITHUB_ENV
echo -e "$FILES" >> $GITHUB_ENV
echo -e "EOF" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: false
files: ${{ env.RELEASE_FILES }}
generate_release_notes: true
draft: true

0 comments on commit 0c963bb

Please sign in to comment.