Last active
November 11, 2024 18:56
-
-
Save bact/159b705c4ac0e5eda38119a6361ebdf2 to your computer and use it in GitHub Desktop.
Convert Python version "3.9" and "pypy3.10" to "cp39" and "pp310" in GitHub Actions
This file contains hidden or 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
jobs: | |
build: | |
steps: | |
- name: Make Python implementation ID (non-Windows) | |
id: convert-version-id | |
if: startsWith(matrix.os, 'windows-') == false | |
run: | | |
PYTHON_VERSION=${{ matrix.python-version }} | |
if [[ "$PYTHON_VERSION" == pypy* ]]; then | |
CP_VER="pp${PYTHON_VERSION:4}" | |
CP_VER="${CP_VER//./}" | |
else | |
CP_VER="cp${PYTHON_VERSION//./}" | |
fi | |
echo "Python version: $CP_VER" | |
echo "CP_VER=$CP_VER" >> $GITHUB_ENV | |
- name: Make Python implementation ID (Windows) | |
id: convert-version-id-win | |
if: startsWith(matrix.os, 'windows-') | |
shell: powershell | |
run: | | |
$PYTHON_VERSION = "${{ matrix.python-version }}" | |
if ($PYTHON_VERSION -like "pypy*") { | |
$CP_VER = "pp" + $PYTHON_VERSION.Substring(4).Replace(".", "") | |
} else { | |
$CP_VER = "cp" + $PYTHON_VERSION.Replace(".", "") | |
} | |
echo "Python version: $CP_VER" | |
echo "CP_VER=$CP_VER" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment