Skip to content

πŸ’š Add python-build #128

πŸ’š Add python-build

πŸ’š Add python-build #128

Workflow file for this run

---
"on":
push:
paths-ignore:
- "**.md"
- docs/*
pull_request:
paths-ignore:
- "**.md"
- docs/*
workflow_dispatch:
# https://github.com/softprops/action-gh-release/issues/236
permissions:
contents: write
env:
files: dist/*
python-version: 3.x
cache: pip
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
shell: bash
# SystemError: PyDescr_NewMember used with Py_RELATIVE_OFFSET
# - runs-on: macos-latest
# shell: bash
- runs-on: windows-latest
shell: msys2
runs-on: ${{matrix.runs-on}}
defaults:
run:
shell: ${{matrix.shell}} {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.python-version}}
cache: ${{env.cache}}
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get -y update
sudo apt-get -y install librime-dev
- name: Install dependencies
if: runner.os == 'macOS'
run: |
brew tap tonyfettes/homebrew-rime
brew install librime
- name: Install dependencies
if: runner.os == 'Windows'
run: |
pacman -Sy --noconfirm mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-librime mingw-w64-x86_64-python-pip \
mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
- name: Test
run: |
pip install .[dev]
pytest --cov
- uses: codecov/codecov-action@v4
build:
needs: test
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
shell: bash
- runs-on: macos-latest
shell: bash
- runs-on: windows-latest
shell: msys2
runs-on: ${{matrix.runs-on}}
defaults:
run:
shell: ${{matrix.shell}} {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.python-version}}
cache: ${{env.cache}}
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get -y update
sudo apt-get -y install librime-dev rename
- name: Install dependencies
if: runner.os == 'macOS'
run: |
brew tap tonyfettes/homebrew-rime
brew install librime
- name: Install dependencies
if: runner.os == 'Windows'
# Dist currently only works with Git or Mercurial repos
run: |
pacman -Sy --noconfirm mingw-w64-x86_64-gcc \
mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-librime \
mingw-w64-x86_64-python-build git
- name: Upgrade version
if: startsWith(github.ref, 'refs/tags/')
run: |
perl -pi -e"s/(?<=version: ')[^']+/$GITHUB_REF_NAME/g" meson.build
- name: Install common dependencies
if: runner.os != 'Windows'
# windows uses msys2's pip's python-build
# ERROR Command '['D:/a/_temp/msys64/mingw64/bin/python.exe', '-m',
# 'pip', '--python',
# 'D:/a/_temp/msys64/tmp/build-env-6w5hd7wi/bin/python.exe', 'install',
# '--use-pep517', '--no-warn-script-location', '--no-compile', '-r',
# 'D:/a/_temp/msys64/tmp/build-reqs-zy4dg0x1.txt']' returned non-zero
# exit status 1.
# ubuntu uses apt's pip's python-build
# ERROR Virtual environment creation failed, executable
# /tmp/build-env-c4hi79lc/local/bin/python missing
run: |
pip install build
- name: Build
run: |
pyproject-build
- if: runner.os == 'Linux'
run: |
rename s/linux/manylinux_2_17/ dist/*
- if: runner.os == 'Windows'
run: |
for file in dist/*
do
new_name=$(echo "$file" | sed 's/mingw_x86_64/win_amd64/g')
if [ "$file" != "$new_name" ]; then
mv "$file" "$new_name"
echo "Renamed $file to $new_name"
fi
done
- uses: actions/upload-artifact@v4
with:
name: artifact-${{matrix.runs-on}}
path: |
${{env.files}}
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/')
with:
password: ${{secrets.PYPI_API_TOKEN}}
- uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
# body_path: build/CHANGELOG.md
files: |
${{env.files}}
deploy-aur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: Freed-Wu/[email protected]
with:
package_name: python-pyrime
ssh_private_key: ${{secrets.AUR_SSH_PRIVATE_KEY}}
deploy-nur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Trigger Workflow
run: >
curl -X POST -d '{"ref": "main"}'
-H "Accept: application/vnd.github.v3+json"
-H "Authorization: Bearer ${{secrets.GH_TOKEN}}"
https://api.github.com/repos/Freed-Wu/nur-packages/actions/workflows/version.yml/dispatches
deploy-ppa:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Build
run: |
n="pyrime-$GITHUB_REF_NAME"
cd ..
mv pyrime "$n"
tar vcaf ./"$n".tar.gz "$n"
mv ./*.tar.* "$n"
mv "$n" pyrime
- uses: Freed-Wu/publish-ppa-package@main
with:
repository: freedwu/rime
extra_ppa: freedwu/rime
gpg_private_key: ${{secrets.GPG_PRIVATE_KEY}}
gpg_passphrase: ${{secrets.GPG_PASSPHRASE}}
tarball: ./*.tar.*
deb_email: ${{secrets.DEB_EMAIL}}
deb_fullname: freedwu
debmake_arguments: -b pyrime:python3