Build (Release) #2
Workflow file for this run
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 (Release)' | |
on: | |
release: | |
types: | |
- created | |
workflow_dispatch: | |
jobs: | |
get-version-number: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: "Get version number" | |
id: get_version | |
run: | | |
export VERSION=$(python -c 'print(__import__("version").VERSION)') | |
export SUB_VER=$(git rev-list --no-merges --count $(git describe --tags --abbrev=0)..HEAD) | |
echo "Currect Version Number: $VERSION.$SUB_VER" | |
echo "SUB_VER = $SUB_VER" >> version.py | |
# Create an environment file | |
echo "VERSION=${VERSION}.${SUB_VER}" >> $GITHUB_OUTPUT | |
echo "SUB_VERSION=${SUB_VER}" >> $GITHUB_OUTPUT | |
outputs: | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
SUB_VERSION: ${{ steps.get_version.outputs.SUB_VERSION }} | |
build-windows: | |
needs: get-version-number | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest] | |
arch: [x86, x64, arm64] | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
- name: "Setup Python" | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.11 # 保证兼容性 | |
- name: "Install requirements" | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U -r requirements.txt | |
pip install -U imageio | |
- name: "Write version number" | |
run: | | |
Add-Content -Path "version.py" -Value "SUB_VER = $env:SUB_VER" | |
Get-Content version.py | |
env: | |
SUB_VER: ${{ needs.get-version-number.outputs.SUB_VERSION }} | |
- name: "Build executeable" | |
uses: Nuitka/Nuitka-Action@v1.0 | |
with: | |
standalone: true | |
onefile: true | |
follow-imports: true | |
show-modules: true | |
output-dir: build | |
lto: yes | |
script-name: main.py | |
windows-icon-from-ico: icon.ico | |
file-version: ${{ needs.get-version-number.outputs.VERSION }} | |
product-version: ${{ needs.get-version-number.outputs.VERSION }} | |
product-name: OneDisc | |
enable-console: true | |
file-description: "OneBot Implementation for Discord" | |
company-name: "IT Craft Development Team" | |
copyright: "Copyright (c) 2023 IT Craft Development Team" | |
- name: "Rename application" | |
run: | | |
Move-Item -Path .\build\main.exe -Destination .\build\onedisc.exe | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: build/onedisc.exe | |
asset_name: OneDisc for ${{ matrix.os }}-${{ matrix.arch }}.exe | |
release_url: ${{ github.event.release.url }} | |
build: | |
needs: get-version-number | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
arch: [x86, x64, arm64] | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
- name: "Setup Python" | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.11 # 保证兼容性 | |
- name: "Install requirements" | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U -r requirements.txt | |
sudo apt install -y zip | |
pip install -U imageio | |
- name: "Write version number" | |
run: | | |
echo "SUB_VER = $SUB_VER" >> version.py | |
env: | |
SUB_VER: ${{ needs.get-version-number.outputs.SUB_VERSION }} | |
- name: "Build executeable" | |
uses: Nuitka/Nuitka-Action@v1.0 | |
with: | |
standalone: true | |
onefile: true | |
follow-imports: true | |
show-modules: true | |
macos-app-icon: icon.ico | |
macos-app-version: ${{ needs.get-version-number.outputs.VERSION }} | |
output-dir: build | |
lto: yes | |
script-name: main.py | |
- name: "Rename application" | |
run: | | |
mv build/main.bin ./build/onedisc | |
cd build | |
zip -r onedisc.zip onedisc | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: build/onedisc.zip | |
asset_name: OneDisc for ${{ matrix.os }}-${{ matrix.arch }}.zip | |
release_url: ${{ github.event.release.url }} | |