workflows #12
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
| name: Build Wheels | ||
|
Check failure on line 1 in .github/workflows/build-wheels.yml
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| tags: | ||
| - "*" | ||
| env: | ||
| PYTHON_VERSIONS: '["3.11","3.12","3.13"]' | ||
| permissions: | ||
| contents: read | ||
| actions: read | ||
| packages: write | ||
| concurrency: | ||
| group: build-wheels-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| get-python-versions: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| py_ver: ${{ steps.set.outputs.py_ver }} | ||
| py_last: ${{ steps.set.outputs.py_last }} | ||
| steps: | ||
| - id: set | ||
| run: | | ||
| echo py_ver=$PYTHON_VERSIONS >> $GITHUB_OUTPUT | ||
| echo "py_last=${{ fromJson(env.PYTHON_VERSIONS)[0] }}" >> $GITHUB_OUTPUT | ||
| check-tag-on-main: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository with full history | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.PAT_TOKEN }} | ||
| fetch-depth: 0 | ||
| - name: Verify tag | ||
| run: | | ||
| git fetch origin main | ||
| TAG_COMMIT=$(git rev-parse ${{ github.ref_name }}) | ||
| if git merge-base --is-ancestor "$TAG_COMMIT" origin/main; then | ||
| echo "::notice::Tag ${{ github.ref_name }} ($TAG_COMMIT) is contained in main" | ||
| else | ||
| echo "::error::Tag ${{ github.ref_name }} ($TAG_COMMIT) is not found in main" | ||
| exit 1 | ||
| fi | ||
| check-tag-privilege: | ||
| # No third party actions used | ||
| uses: scikit-package/release-scripts/.github/workflows/_check-tag-privilege.yml@v0 | ||
| with: | ||
| maintainer_github_username: Tieqiong | ||
| build-sdist: | ||
| needs: [check-tag-privilege, get-python-versions, check-tag-on-main] | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
| steps: | ||
| - name: Checkout | ||
| # GitHub officially-maintained actions | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up Python | ||
| # GitHub officially-maintained actions | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ needs.py_ver.outputs.py_last }} | ||
| # - name: Make sdist | ||
| # run: | | ||
| # python -m pip install --upgrade pip build cython setuptools setuptools-git-versioning | ||
| # python -m build --sdist --no-isolation | ||
| # - name: Strip source codes | ||
| # run: | | ||
| # set -euo pipefail | ||
| # tar xf dist/diffpy_pdfgetx-*.tar.gz | ||
| # SRC_DIR=$(find . -maxdepth 1 -type d -name 'diffpy_pdfgetx-*' | head -n1) | ||
| # find "$SRC_DIR" -type f -name '*.c' -print0 \ | ||
| # | xargs -0 perl -i.bak -0777 -pe 's{/\*.*?\*/}{}gs' | ||
| # find "$SRC_DIR" -type f -name '*.c.bak' -delete | ||
| # tar czf dist/"${SRC_DIR#./}".tar.gz "$SRC_DIR" | ||
| # rm -rf "$SRC_DIR" | ||
| # - name: Upload sdist | ||
| # # GitHub officially-maintained actions | ||
| # uses: actions/upload-artifact@v4 | ||
| # with: | ||
| # name: sdist | ||
| # path: dist/ | ||
| # retention-days: 1 | ||
| build-wheels: | ||
| needs: [py_ver, build-sdist] | ||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
| name: Build wheels ${{ matrix.python }}-${{ matrix.buildplat }} | ||
| runs-on: ${{ matrix.buildplat }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| buildplat: | ||
| - ubuntu-latest | ||
| - macos-13 | ||
| - macos-14 | ||
| - windows-latest | ||
| python: ${{ fromJSON(needs.py_ver.outputs.py_ver) }} | ||
| steps: | ||
| # - name: Download sdist | ||
| # # GitHub officially-maintained actions | ||
| # uses: actions/download-artifact@v4 | ||
| # with: | ||
| # name: sdist | ||
| # path: dist/ | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| # - name: Build wheels | ||
| # run: | | ||
| # # setuptools-git-versioning only look into .git and PKG-INFO in the top directory | ||
| # python -m pip install --upgrade pip build cython setuptools setuptools-git-versioning | ||
| # tar xf dist/diffpy_pdfgetx-*.tar.gz | ||
| # cd diffpy_pdfgetx-* | ||
| # python -m pip wheel . --no-deps --no-build-isolation --wheel-dir ./../dist | ||
| - name: make fake wheel | ||
| run: | | ||
| mkdir -p dist | ||
| touch dist/diffpy_pdfgetx-0.0.0-${{ matrix.python }}-${{ matrix.buildplat }}.whl | ||
| - name: Upload wheels | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheels-${{ matrix.python }}-${{ matrix.buildplat }} | ||
| path: dist/*.whl | ||
| test-wheels: | ||
| needs: [py_ver, build-wheels] | ||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
| name: Test wheels ${{ matrix.python }}-${{ matrix.buildplat }} | ||
| runs-on: ${{ matrix.buildplat }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| buildplat: | ||
| - ubuntu-latest | ||
| - macos-13 | ||
| - macos-14 | ||
| - windows-latest | ||
| python: ${{ fromJson(needs.py_ver.outputs.py_ver) }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| # - name: Download wheels | ||
| # uses: actions/download-artifact@v4 | ||
| # with: | ||
| # name: wheels-${{ matrix.python }}-${{ matrix.buildplat }} | ||
| # path: dist/ | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| # - name: Install wheels | ||
| # run: | | ||
| # python -m pip install --upgrade pip pytest setuptools-git-versioning | ||
| # python -m pip install dist/*.whl | ||
| # - name: Assert no source files in installed package | ||
| # run: | | ||
| # # For debugging | ||
| # # touch $(python -c "import sysconfig, os; print(os.path.join(sysconfig.get_paths()['purelib'], 'diffpy/pdfgetx', 'fake.py'))") | ||
| # python - << 'EOF' | ||
| # import os, glob, sys, sysconfig | ||
| # sp = sysconfig.get_paths()['purelib'] | ||
| # pkg = os.path.join(sp, 'diffpy', 'pdfgetx') | ||
| # patterns = [os.path.join(pkg, '*.py'), | ||
| # os.path.join(pkg, '*.c')] | ||
| # bad = [] | ||
| # for p in patterns: | ||
| # bad.extend(glob.glob(p)) | ||
| # if bad: | ||
| # print("Found leftover source files in installed package:") | ||
| # for f in bad: | ||
| # print(" -", f) | ||
| # sys.exit(1) | ||
| # print("No .py or .c files present in diffpy/pdfgetx/") | ||
| # EOF | ||
| # - name: Run tests | ||
| # run: python -m pytest | ||
| release: | ||
| needs: [test-wheels] | ||
| uses: ./.github/workflows/release-github.yml | ||
| secrets: | ||
| PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | ||