Build and Publish #12
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
# This workflow will upload a Python Package using Twine when a release is created | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
# It will also use PyInstaller to create a Windows executable and upload it to the GitHub release | |
name: Build and Publish | |
on: | |
release: | |
types: [published] | |
jobs: | |
windows-build: | |
runs-on: windows-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
token: ${{ secrets.REPO_SCOPED_TOKEN }} | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
git submodule update --init --recursive | |
python -m pip install --upgrade pip | |
pip install PyInstaller wheel | |
if (Test-Path requirements.txt) {pip install -r requirements.txt} | |
- name: Build executable with PyInstaller | |
run: | | |
python tools/create_exe.py | |
Compress-Archive -Path dist/* -Destination windows_release.zip | |
dir | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-executable-windows-zip | |
path: windows_release.zip | |
linux-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
token: ${{ secrets.REPO_SCOPED_TOKEN }} | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
git submodule update --init --recursive | |
python -m pip install --upgrade pip | |
pip install PyInstaller wheel | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Build executable with PyInstaller | |
run: | | |
python tools/create_exe.py | |
tar -czvf linux_release.tar.gz dist/* | |
dir | |
- name: Generate blocklist | |
run: | | |
python tools/hashnames.py | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-executable-linux-zip | |
path: linux_release.tar.gz | |
- name: Upload Blocklist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: blocklist | |
path: blocklist | |
executable-upload: | |
runs-on: ubuntu-latest | |
needs: [windows-build, linux-build] | |
permissions: | |
contents: write | |
steps: | |
- name: Download windows executable for job windows-build | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-executable-windows-zip | |
- name: Download linux executable for job linux-build | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-executable-linux-zip | |
- name: Download blocklist | |
uses: actions/download-artifact@v3 | |
with: | |
name: blocklist | |
- name: Upload zipped windows executable to release | |
uses: JasonEtco/upload-to-release@master | |
with: | |
args: windows_release.zip application/zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload tarballed linux executable to release | |
uses: JasonEtco/upload-to-release@master | |
with: | |
args: linux_release.tar.gz application/zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload blocklist | |
uses: JasonEtco/upload-to-release@master | |
with: | |
args: blocklist text/plain | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
pypi-publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build PyInstaller wheel | |
- name: Build package | |
run: python -m build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |