Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create release workflow for windows and macos #12

Merged
merged 13 commits into from
Sep 12, 2024
Merged
59 changes: 42 additions & 17 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,75 @@ jobs:
name: version-file
path: version

deploy:

runs-on: ubuntu-latest
build_wheels:
runs-on: ${{ matrix.os }}
needs: [create_version]
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
include:
- os: ubuntu-latest
arch: x86_64
- os: windows-latest
arch: auto
- os: macos-latest
arch: auto

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build auditwheel patchelf
pip install build cibuildwheel

- uses: actions/download-artifact@master
with:
name: version-file
path: version

- name: Build package
env:
CIBW_BUILD: "cp310* cp311* cp312*"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: "*musllinux*"
run: |
export TypedUnits_RELEASE_VERSION="$(cat version/version.txt)"
python -m build
python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

release-wheels:
name: Publish all wheels
needs: [build_wheels]
runs-on: ubuntu-latest

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
merge-multiple: true
path: wheelhouse/

- name: Repair Wheel
run: |
auditwheel repair --plat manylinux2014_x86_64 dist/*.whl
rm dist/*.whl
mv wheelhouse/* dist/
rm dist/*.tar.gz

- name: Publish package to testpypi
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
repository_url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true

- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true
61 changes: 43 additions & 18 deletions .github/workflows/stable-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,75 @@ jobs:
name: version-file
path: version

deploy:

runs-on: ubuntu-latest
build_wheels:
runs-on: ${{ matrix.os }}
needs: [create_version]
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12"]
include:
- os: ubuntu-latest
arch: x86_64
- os: windows-latest
arch: auto
- os: macos-latest
arch: auto

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build auditwheel patchelf
pip install build cibuildwheel

- uses: actions/download-artifact@master
with:
name: version-file
path: version

- name: Build package
env:
CIBW_BUILD: "cp310* cp311* cp312*"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: "*musllinux*"
run: |
export TypedUnits_RELEASE_VERSION="$(cat version/version.txt)"
python -m build
python -m cibuildwheel --output-dir wheelhouse

- name: Repair Wheel
run: |
auditwheel repair --plat manylinux2014_x86_64 dist/*.whl
rm dist/*.whl
mv wheelhouse/* dist/
rm dist/*.tar.gz

- name: Publish package
- uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

release-wheels:
name: Publish all wheels
needs: [build_wheels]
runs-on: ubuntu-latest

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
merge-multiple: true
path: wheelhouse/

- name: Publish package to testpypi
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
repository_url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true

- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
requirements = open('requirements.txt', 'r').readlines()


_VERSION_KEY = 'TypedUnits_RELEASE_VERSION'
__version__ = os.environ.get(_VERSION_KEY, '')
__version__ = ''
if os.path.exists('version/version.txt'):
__version__ = open('version/version.txt').read().strip()

if not __version__:
# Local build
import _version
Expand Down