Build And Release #69
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
name: Build And Release | |
on: | |
push: | |
paths: | |
- '**.yml' | |
workflow_dispatch: | |
inputs: | |
release: | |
description: 'Create a new release' | |
required: true | |
default: true | |
type: boolean | |
version: | |
description: 'Release version' | |
required: true | |
default: '2024.09.09.v2' | |
body: | |
description: 'Release body text' | |
required: true | |
default: '详情请查看更新日志' | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set release outputs | |
id: set_release_outputs | |
run: | | |
if [ "${{ github.event.inputs.release }}" == "true" ]; then | |
echo "TAG=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
echo "BODY=${{ github.event.inputs.body }}" >> $GITHUB_ENV | |
else | |
echo "TAG=$(date +'%Y.%m.%d.v1')" >> $GITHUB_ENV | |
echo "BODY=详情请查看更新日志" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11.9 | |
- name: Install Pyinstaller | |
run: | | |
python -m pip install pyinstaller | |
python -m pip install -r requirements.txt | |
- name: Build the executables | |
run: | | |
pyinstaller --onefile --name epub_tool epub_tool.py | |
- name: Rename artifacts with OS prefix (Linux and macOS) | |
if: matrix.os != 'windows-latest' | |
run: | | |
for file in dist/*; do | |
mv "$file" "dist/${{ runner.os }}_$(basename "$file")" | |
done | |
shell: bash | |
- name: Rename artifacts with OS prefix (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
Get-ChildItem -Path dist | Rename-Item -NewName { '${{ runner.os }}_' + $_.Name } | |
shell: pwsh | |
# - name: Create zip archive (Windows) | |
# if: matrix.os == 'windows-latest' | |
# run: | | |
# Compress-Archive -Path dist\* -DestinationPath "dist\${{ runner.os }}_all.zip" | |
# shell: pwsh | |
# - name: Create tar.gz archive (Linux and macOS) | |
# if: matrix.os != 'windows-latest' | |
# run: | | |
# tar -czvf "${{ runner.os }}_all.tar.gz" -C dist $(ls dist) | |
# mv "${{ runner.os }}_all.tar.gz" dist/ | |
# shell: bash | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ env.TAG }} | |
name: ${{ env.TAG }} | |
body: ${{ env.BODY }} | |
artifacts: 'dist/*' | |
allowUpdates: true | |
makeLatest: true |