Fix artifact name and add code to upload binaries to release #11
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: Check and Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
release: | |
types: [released] | |
permissions: read-all | |
jobs: | |
build-executable: | |
name: Build binary for linux | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Apt packages | |
id: cache-apt | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
execute_install_scripts: true | |
packages: libfuse-dev | |
version: 1.0 | |
- name: Checkout the Git repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Nuitka ccache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.nuitka | |
key: ${{ github.job }}-ccache-ubuntu-latest | |
- name: Build with nuitka | |
run: | | |
pip install -r requirements.txt wheel nuitka | |
mkdir -p dist | |
NUITKA_CACHE_DIR="${{ github.workspace }}/.nuitka" \ | |
python -m nuitka \ | |
--enable-plugin=pylint-warnings \ | |
--onefile \ | |
--lto=yes \ | |
--assume-yes-for-downloads \ | |
--remove-output \ | |
--output-dir=dist \ | |
--output-filename=rmufuse \ | |
remarkable_update_fuse/__main__.py | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: rmufuse | |
path: dist | |
if-no-files-found: error | |
build-wheel: | |
name: Build wheel with python ${{ matrix.python }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: | |
- '3.11' | |
steps: | |
- name: Checkout the Git repository | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
- name: Install build tool | |
run: pip install build | |
- name: Building package | |
run: python -m build --wheel | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pip-wheel-${{ matrix.python }} | |
path: dist/* | |
if-no-files-found: error | |
build-sdist: | |
name: Build sdist | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the Git repository | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install build tool | |
run: pip install build | |
- name: Building package | |
run: python -m build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pip-sdist | |
path: dist/* | |
if-no-files-found: error | |
publish: | |
name: Publish to PyPi | |
if: github.repository == 'Eeems-Org/remarkable-update-fuse' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags') | |
needs: [build-sdist, build-wheel] | |
strategy: | |
matrix: | |
artifact: | |
- 'wheel-3.11' | |
- 'sdist' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
environment: | |
name: pypi | |
url: https://pypi.org/p/remarkable_update_fuse | |
steps: | |
- name: Download pip packages | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: pip-${{ matrix.artifact }} | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: ${{ steps.download.outputs.download-path }} | |
skip-existing: true | |
release: | |
name: Add binaries to release | |
if: github.repository == 'Eeems-Org/remarkable-update-fuse' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags') | |
needs: [build-executable] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Download executable | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: rmufuse | |
- name: Upload to release | |
run: | |
hub release edit \ | |
--attach ${{ steps.download.outputs.download-path }}/rmufuse \ | |
"$TAG" | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
TAG: ${{ github.event.release.tag_name }} |