Skip to content

Fixing GitHub Actions (#222) #1

Fixing GitHub Actions (#222)

Fixing GitHub Actions (#222) #1

name: Test, Build, and Publish
# FIXME:
# Unable to release with windows-latest
# ERROR in GitHub Actions:
# [pipenv.exceptions.InstallError]: ERROR: Could not find a version that satisfies the requirement pywin32==227 (from versions: 302)
# [pipenv.exceptions.InstallError]: ERROR: No matching distribution found for pywin32==227
# ERROR: Couldn't install package: pywin32
# docker python package REQUIRES pywin32==227 !!
# Probably don't need pipywin32 ...
on:
push:
branches:
- main
- release-binary
# - '*' # matches every branch that doesn't contain a '/'
# - '*/*' # matches every branch containing a single '/'
# - '**' # matches every branch
# - '!main' # excludes main
tags:
- "*"
jobs:
test:
name: Testing
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest] #, windows-latest] # ! FIXME: Add windows
python-version: ['3.10'] # ! FIXME: Add 3.7
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update apt package repositories
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update
- name: Install Linux simpleaudio dependency
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y python3-dev libasound2-dev
- name: Install/Upgrade Python tooling
run: python -m pip install --upgrade pip pipenv virtualenv wheel setuptools
- id: cache-pipenv
uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install dependencies if not in cache
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: pipenv sync --dev
- name: Stupid hack for installing pylint on MacOS
if: matrix.os == 'macos-latest'
run: pipenv run pip install pylint
# - name: Show all dependencies (pipenv)
# run: pipenv graph --bare
- name: Show all dependencies (pip)
run: pipenv run pip list
- name: Code Linting
run: pipenv run pylint ./yojenkins --rcfile=.pylintrc
- name: Build the package
run: pipenv run python setup.py install --verbose
- name: Testing --help
run: pipenv run yojenkins --help
# --------------------------------------------------------------------------
build-package:
name: Building Package
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update apt package repositories
run: sudo apt-get update
- name: Install Linux simpleaudio dependency
run: sudo apt-get install -y python3-dev libasound2-dev
- name: Install/Upgrade Python tooling
run: python -m pip install --upgrade pip pipenv virtualenv wheel setuptools
- id: cache-pipenv
uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install dependencies if not in cache
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: pipenv sync --dev
- name: Stupid hack for installing pylint on MacOS
if: matrix.os == 'macos-latest'
run: pipenv run pip install pylint
- name: Install pypa/build tooling
run: pipenv run python -m pip install build
# - name: Show all dependencies (pipenv)
# run: pipenv graph --bare
- name: Show all dependencies (pip)
run: pipenv run pip list
- name: Create release version tag
id: release
run: echo "::set-output name=release_version_tag::$(cat VERSION)"
- name: Build a package wheel and tarball
run: pipenv run python setup.py sdist bdist_wheel
- uses: actions/upload-artifact@v3
with:
name: pypi-distribution
path: dist/
if-no-files-found: error
retention-days: 1
outputs:
release_version_tag: ${{ steps.release.outputs.release_version_tag }}
# --------------------------------------------------------------------------
build-binaries:
name: Building Binaries
needs: [test]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest] #, windows-latest]
python-version: [3.9]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Update apt package repositories
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update
- name: Install Linux simpleaudio dependency
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y python3-dev libasound2-dev
- name: Install/Upgrade Python tooling
run: python -m pip install --upgrade pip pipenv virtualenv wheel setuptools
- id: cache-pipenv
uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install dependencies if not in cache
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: pipenv sync --dev
- name: Stupid hack for installing pylint on MacOS
if: matrix.os == 'macos-latest'
run: pipenv run pip install pylint
# - name: Show all dependencies (pipenv)
# run: pipenv graph --bare
- name: Show all dependencies (pip)
run: pipenv run pip list
- name: Build with PyInstaller
env:
PYTHONOPTIMIZE: 1 # Enable optimizations as if the -O flag is given.
PYTHONHASHSEED: 42 # Try to ensure deterministic results.
run: pipenv run pyinstaller pyinstaller-onefile.spec -y --clean
- name: Create release version tag
id: release
run: echo "::set-output name=release_version_tag::$(cat VERSION)"
- name: Rename binary artifact (Linux)
if: (matrix.os == 'ubuntu-latest')
run: mv dist/yojenkins* dist/yojenkins-${{ steps.release.outputs.release_version_tag }}-linux-x86_64
- name: Rename binary artifact (MacOS)
if: (matrix.os == 'macos-latest')
run: mv dist/yojenkins* dist/yojenkins-${{ steps.release.outputs.release_version_tag }}-macos-x86_64
- name: Rename binary artifact (Windows)
if: (matrix.os == 'windows-latest')
run: mv dist/yojenkins*.exe dist/yojenkins-${{ steps.release.outputs.release_version_tag }}-windows-x86_64.exe
- uses: actions/upload-artifact@v3
with:
name: binary-${{ runner.os }}
path: dist/
if-no-files-found: error
retention-days: 1
outputs:
release_version_tag: ${{ steps.release.outputs.release_version_tag }}
# --------------------------------------------------------------------------
release-package-to-github:
name: Releasing Package to GitHub Releases
needs: [build-package]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: pypi-distribution
path: dist/
- name: Create GitHub Release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: v${{ needs.build-package.outputs.release_version_tag }}
artifacts: "dist/*"
# body: "testing"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
# --------------------------------------------------------------------------
release-binary-to-github:
name: Releasing Binaries to GitHub Releases
needs: [build-binaries]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest] #, windows-latest]
python-version: [3.9]
steps:
- uses: actions/download-artifact@v3
with:
name: binary-${{ runner.os }}
path: dist/
- name: Use the value
id: step_two
run: echo "${{ needs.build-binaries.outputs.release_version_tag }}" # This will output 'yellow'
- name: Create GitHub Release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: v${{ needs.build-binaries.outputs.release_version_tag }}
artifacts: "dist/*"
# body: ""
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
# --------------------------------------------------------------------------
release-package-to-pypi:
name: Releasing Package to PyPI
needs: [build-package, release-package-to-github, release-binary-to-github]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: pypi-distribution
path: dist/
- name: Publish distribution package to TEST PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true