Release (All) #54
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: Release (Windows) | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Version Number (x.y.z)" | |
required: true | |
type: string | |
release: | |
description: "Create Release?" | |
required: false | |
default: false | |
type: boolean | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version || steps.custom.outputs.version || steps.tag.outputs.version }} | |
steps: | |
- name: Output Version | |
id: version | |
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.version == '' ) }} | |
run: echo "version=$(date +'%Y%m%d-%H%M')" >> $GITHUB_OUTPUT | |
- name: Output Custom Version | |
id: custom | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version != '' }} | |
run: echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
- name: Output Tag | |
id: tag | |
if: ${{ github.event_name == 'push' }} | |
run: echo "version=$(echo ${GITHUB_REF#refs/*/} | sed -e 's/v//')" >> $GITHUB_OUTPUT | |
build-windows: | |
# Windows is currently the only platform this action supports | |
needs: [version] | |
runs-on: windows-2019 | |
steps: | |
# Check-out repository | |
- uses: actions/checkout@v4 | |
- name: Install Visual C++ Redistributable | |
run: | | |
choco install vcredist2015 | |
# Setup Python | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax | |
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified | |
cache: 'pip' | |
# cache-dependency-path: | | |
# **/requirements*.txt | |
# Install dependencies | |
- name: Install Dependencies | |
run: | | |
pip install poetry | |
poetry config virtualenvs.in-project true | |
poetry install --no-root | |
# Uncomment to printout environment paths and python setup | |
# poetry run python .\python-env.py | |
# Build zip folder with executable using pyinstaller | |
- name: Build zip file | |
run: | | |
cp .\.github\pyinstaller\gesture-mouse.spec.win gesture-mouse.spec | |
poetry run pyinstaller.exe gesture-mouse.spec --clean --noconfirm | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gesture-mouse-${{ needs.version.outputs.version }} | |
include-hidden-files: true | |
path: dist/gesture-mouse | |
build-linux: | |
# Windows is currently the only platform this action supports | |
needs: [version] | |
runs-on: ubuntu-20.04 | |
steps: | |
# Check-out repository | |
- uses: actions/checkout@v4 | |
with: | |
path: build-linux | |
# Setup Python | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax | |
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified | |
cache: 'pip' | |
# cache-dependency-path: | | |
# **/requirements*.txt | |
# Install dependencies | |
- name: Install Dependencies | |
run: | | |
pip install poetry | |
poetry config virtualenvs.in-project true | |
poetry install --no-root | |
# Uncomment to printout environment paths and python setup | |
# poetry run python .\python-env.py | |
# Build zip folder with executable using pyinstaller | |
- name: Build zip file | |
run: | | |
cp ./.github/pyinstaller/gesture-mouse.spec.linux gesture-mouse.spec | |
poetry run pyinstaller gesture-mouse.spec --clean --noconfirm | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gesture-mouse-linux-${{ needs.version.outputs.version }} | |
include-hidden-files: true | |
path: dist/gesture-mouse | |
release: | |
needs: [version, build-windows] | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.release.outputs.upload_url }} # Set job-level output | |
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true') | |
steps: | |
- name: Create Release | |
id: release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.version.outputs.version }} | |
release_name: Release ${{ needs.version.outputs.version }} | |
draft: false | |
prerelease: false | |
release-upload: | |
runs-on: ubuntu-latest | |
needs: [version, build-windows, release] | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: gesture-mouse-${{ needs.version.outputs.version }} | |
path: gesture-mouse-${{ needs.version.outputs.version }} | |
- name: Display structure of downloaded files | |
run: | | |
ls | |
zip -r gesture-mouse-${{ needs.version.outputs.version }}.zip ./gesture-mouse-${{ needs.version.outputs.version }}/ | |
ls | |
- name: upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ./gesture-mouse-${{ needs.version.outputs.version }}.zip | |
asset_name: gesture-mouse-${{ needs.version.outputs.version }}.zip | |
asset_content_type: application/zip |