Skip to content

test windows

test windows #26

Workflow file for this run

name: Build and Release
on:
push:
branches:
- fix-ci
- dev
- master
paths:
- '**.py'
- '**.yml'
- '**.yaml'
- 'pyproject.toml'
- 'pdm.lock'
permissions:
contents: write
actions: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest] #[macos-latest, windows-latest]
python-version: [3.11]
include:
# - os: macos-latest
# spec: GameYamlSpider.spec
- os: windows-latest
spec: GameYamlSpider.spec
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get Version from pyproject.toml (Unix)
if: runner.os != 'Windows'
run: |
version=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)
echo "version=$version" >> $GITHUB_ENV
- name: Get Version from pyproject.toml (Windows)
if: runner.os == 'Windows'
run: |
$version = (sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)
echo "version=$version" >> $env:GITHUB_ENV
- name: Get Last Commit Version (Unix)
if: runner.os != 'Windows'
run: |
commit_version=$(git show HEAD^:pyproject.toml | grep '^version' | sed 's/^version = "\(.*\)"/\1/')
echo "last_commit_version=$commit_version" >> $GITHUB_ENV
- name: Get Last Commit Version (Windows)
if: runner.os == 'Windows'
run: |
$commit_version = (git show HEAD^:pyproject.toml | grep '^version' | sed 's/^version = "\(.*\)"/\1/')
if (!$commit_version) { $commit_version = "none" }
echo "last_commit_version=$commit_version" >> $env:GITHUB_ENV
- name: Check if Versions Match (Unix)
if: runner.os != 'Windows'
run: |
if [[ "${{ env.version }}" == "${{ env.last_commit_version }}" ]]; then
echo "skip_build=true" >> $GITHUB_ENV
else
echo "skip_build=false" >> $GITHUB_ENV
fi
- name: Check if Versions Match (Windows)
if: runner.os == 'Windows'
run: |
if ("${{ env.version }}" -eq "${{ env.last_commit_version }}") {
echo "skip_build=true" >> $env:GITHUB_ENV
} else {
echo "skip_build=false" >> $env:GITHUB_ENV
}
- name: Cache PDM dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pdm
~/.cache/pip
key: ${{ runner.os }}-pdm-${{ matrix.python-version }}-${{ hashFiles('pdm.lock', 'pyproject.toml') }}
if: env.skip_build != 'true'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
if: env.skip_build != 'true'
- name: Install PDM
run: pip install pdm
if: env.skip_build != 'true'
- name: Install Dependencies
run: |
pdm install
pip install pyinstaller
if: env.skip_build != 'true'
- name: Build Binary with PyInstaller
run: |
pdm run pyinstaller GameYamlSpider.spec
env:
PATH: ${{ github.workspace }}/.pdm/bin:${{ env.PATH }}
if: env.skip_build != 'true'
- name: Package with Zipfile (Unix)
if: runner.os != 'Windows' && env.skip_build != 'true'
run: python -m zipfile -c dist/GameYamlSpider.zip dist/GameYamlSpider
- name: Package with Zipfile (Windows)
if: runner.os == 'Windows' && env.skip_build != 'true'
run: python -m zipfile -c dist\GameYamlSpider.zip dist\GameYamlSpider
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Set Is Pre-release
id: prerelease-check
run: |
if [[ "${{ env.version }}" =~ (a|b|dev|rc)$ ]]; then
echo "This is a pre-release version. Skipping GitHub release."
echo "pre_release=true" >> $GITHUB_ENV
else
echo "This is a stable release."
echo "pre_release=false" >> $GITHUB_ENV
fi
- name: Create Release
if: env.pre_release == 'false'
uses: actions/create-release@v1
with:
tag_name: v${{ env.version }}
release_name: Release v${{ env.version }}
draft: false
prerelease: ${{ env.pre_release }}
- name: Upload Release Assets
if: env.pre_release == 'false'
uses: actions/upload-artifact@v4
with:
repo: ${{ github.repository }}
release_id: ${{ steps.create-release.outputs.id }}
asset_path: dist/GameYamlSpider.zip
asset_name: ${{ matrix.os }}-binary-${{ env.version }}.zip
asset_content_type: application/zip