build: keep appropriate library to specific OS #80
Workflow file for this run
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
# This workflow will upload a Python Package using Twine when a release is created | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Upload Python Package | |
on: | |
push: | |
tags: | |
- '*' | |
release: | |
types: [published] | |
jobs: | |
build-shared-library: | |
strategy: | |
matrix: | |
# Currently use ubuntu 20.04 to aviod GLIBC verion issue | |
runs-on: [ubuntu-20.04, windows-latest, macos-13] | |
runs-on: ${{ matrix.runs-on }} | |
if: startsWith(github.ref, 'refs/tags/') || github.event_name != 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Golang | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22.x' | |
check-latest: true | |
- name: Build windows shared library | |
run: | | |
go env -w CGO_ENABLED="1" | |
make | |
- name: Set file name windows | |
if: matrix.runs-on == 'windows-latest' | |
shell: pwsh | |
run: | | |
echo "filename=pyfastexcel.dll" >> $env:GITHUB_ENV | |
- name: Set file name ubuntu | |
if: matrix.runs-on == 'ubuntu-latest' | |
run: echo "filename=pyfastexcel.so" >> "$GITHUB_ENV" | |
- name: Set file name macos | |
if: matrix.runs-on == 'macos-13' | |
run: echo "filename=pyfastexcel.dylib" >> "$GITHUB_ENV" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.runs-on }}-shared-library | |
path: ./pyfastexcel/${{ env.filename }} | |
test-release: | |
runs-on: ubuntu-latest | |
needs: [build-shared-library] | |
strategy: | |
matrix: | |
runs-on: [ubuntu-20.04, windows-latest, macos-13] | |
permissions: | |
id-token: write | |
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- run: | | |
mv ./pyfastexcel.so ./pyfastexcel | |
mv ./pyfastexcel.dll ./pyfastexcel | |
mv ./pyfastexcel.dylib ./pyfastexcel | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel | |
- name: Build the wheel | |
run: python setup.py bdist_wheel | |
- name: Publish distribution to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
release-job: | |
runs-on: ubuntu-latest | |
needs: [build-shared-library] | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- run: | | |
mv ./pyfastexcel.so ./pyfastexcel | |
mv ./pyfastexcel.dll ./pyfastexcel | |
mv ./pyfastexcel.dylib ./pyfastexcel | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python -m build | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |