From c3b60a093c95750c19b92f1018809611af6820f6 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Fri, 29 May 2020 17:55:28 -0400 Subject: [PATCH 1/2] Add standard workflow and move setup requires into pyproject.toml --- .github/workflows/release.yml | 247 ++++++++++++++++++++++++++++++---- pyproject.toml | 3 + setup.cfg | 5 - 3 files changed, 224 insertions(+), 31 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fc24a8..02ceb3a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,11 @@ -name: Build and release +name: Build and Release + on: push: branches: - - master - - maintenance/* + - conda + # - master + # - maintenance/* create: tags: - 'v[0-9]+.[0-9]+.[0-9]+*' @@ -12,46 +14,206 @@ defaults: run: shell: bash +env: + PACKAGE_NAME: labscript + SCM_VERSION_SCHEME: release-branch-semver + SCM_LOCAL_SCHEME: no-local-version + ANACONDA_USER: labscript-suite + + # Configuration for a package with compiled extensions: + # PURE: false + # NOARCH: false + + # Configuration for a package with no extensions, but with dependencies that differ by + # platform or Python version: + # PURE: true + # NOARCH: false + + # Configuration for a package with no extensions and the same dependencies on all + # platforms and Python versions. For this configuration you should comment out all but + # the first entry in the job matrix of the build job since multiple platforms are not + # needed. + PURE: true + NOARCH: true + jobs: build: - name: Build and Release - runs-on: ubuntu-latest - env: - PACKAGE_NAME: labscript - SCM_VERSION_SCHEME: release-branch-semver - SCM_LOCAL_SCHEME: no-local-version + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - { os: ubuntu-latest, python: 3.8, arch: x64 } + # - { os: ubuntu-latest, python: 3.7, arch: x64 } + # - { os: ubuntu-latest, python: 3.6, arch: x64 } + + # - { os: macos-latest, python: 3.8, arch: x64 } + # - { os: macos-latest, python: 3.7, arch: x64 } + # - { os: macos-latest, python: 3.6, arch: x64 } + + # - { os: windows-latest, python: 3.8, arch: x64 } + # - { os: windows-latest, python: 3.7, arch: x64 } + # - { os: windows-latest, python: 3.6, arch: x64 } + + # - { os: windows-latest, python: 3.8, arch: x86 } + # - { os: windows-latest, python: 3.7, arch: x86 } + # - { os: windows-latest, python: 3.6, arch: x86 } + if: github.repository == 'labscript-suite/labscript' && (github.event_name != 'create' || github.event.ref_type != 'branch') steps: - name: Checkout uses: actions/checkout@v2 - - name: Unshallow + with: + fetch-depth: 0 + + - name: Ignore Tags if: github.event.ref_type != 'tag' - run: | - git fetch --prune --unshallow - git tag -d $(git tag --points-at HEAD) + run: git tag -d $(git tag --points-at HEAD) + - name: Install Python uses: actions/setup-python@v2 with: - python-version: 3.8 - - name: Build Distributions + python-version: ${{ matrix.python }} + architecture: ${{ matrix.arch }} + + - name: Source Distribution + if: strategy.job-index == 0 + run: | + python -m pip install --upgrade pip setuptools wheel pep517 + python -m pep517.build -s . + + - name: Wheel Distribution + # Impure Linux wheels are built in the manylinux job. + if: (env.PURE == 'true' && strategy.job-index == 0) || (env.PURE == 'false' && runner.os != 'Linux') + run: | + python -m pip install --upgrade pip setuptools wheel pep517 + python -m pep517.build -b . + + - name: Upload Artifact + if: strategy.job-index == 0 || (env.PURE == 'false' && runner.os != 'Linux') + uses: actions/upload-artifact@v2 + with: + name: dist + path: ./dist + + - name: Set Variables for Conda Build run: | - python -m pip install --upgrade pip setuptools wheel - pip install -U git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5fd42cb257c86e6dbe720eaee6d1e2c9b - python setup.py sdist bdist_wheel - SCM_VERSION=$(python setup.py --version) - echo "::set-env name=SCM_VERSION::$SCM_VERSION" - - name: Publish on TestPyPI - if: github.event.ref_type == 'tag' || contains(env.SCM_VERSION, 'dev') - uses: pypa/gh-action-pypi-publish@master + if [ $RUNNER_OS == Windows ] && [ ${{ matrix.arch }} == x64 ]; then + CONDA_INSTALLER=Miniconda3-latest-Windows-x86_64.exe + elif [ $RUNNER_OS == Windows ]; then + CONDA_INSTALLER=Miniconda3-latest-Windows-x86.exe + elif [ $RUNNER_OS == Linux ]; then + CONDA_INSTALLER=Miniconda3-latest-Linux-x86_64.sh + else + CONDA_INSTALLER=Miniconda3-latest-MacOSX-x86_64.sh + fi + if [ $NOARCH == true ]; then + CONDA_BUILD_ARGS="--noarch" + else + CONDA_BUILD_ARGS="" + fi + echo "::set-env name=CONDA_INSTALLER::$CONDA_INSTALLER" + echo "::set-env name=CONDA_BUILD_ARGS::$CONDA_BUILD_ARGS" + + - name: Conda package (Unix) + if: runner.os != 'Windows' + run: | + curl -LO https://repo.continuum.io/miniconda/$CONDA_INSTALLER + bash "$CONDA_INSTALLER" -b -p .miniconda + source .miniconda/etc/profile.d/conda.sh + conda activate + conda update -n base -c defaults conda + conda create -n py${{ matrix.python }} python=${{ matrix.python }} + conda activate py${{ matrix.python }} + conda install -c cbillington setuptools-conda + pip install --upgrade setuptools_scm + setuptools-conda build $CONDA_BUILD_ARGS . + + - name: Conda Package (Windows) + if: runner.os == 'Windows' + shell: cmd + run: | + curl -LO https://repo.continuum.io/miniconda/%CONDA_INSTALLER% + %CONDA_INSTALLER% /S /D=%CD%\.miniconda && ^ + .miniconda\Scripts\activate && ^ + conda update -n base -c defaults conda && ^ + conda create -n py${{ matrix.python }} python=${{ matrix.python }} && ^ + conda activate py${{ matrix.python }} && ^ + conda install -c cbillington setuptools-conda && ^ + pip install --upgrade setuptools_scm && ^ + setuptools-conda build %CONDA_BUILD_ARGS% . + + - name: Upload Artifact + uses: actions/upload-artifact@v2 with: - user: __token__ - password: ${{ secrets.testpypi }} - repository_url: https://test.pypi.org/legacy/ + name: conda_packages + path: ./conda_packages + + + manylinux: + name: Build Manylinux + runs-on: ubuntu-latest + strategy: + matrix: + include: + - { python: 'cp36-cp36m cp37-cp37m cp38-cp38' } + + if: github.repository == 'labscript-suite/labscript' && (github.event_name != 'create' || github.event.ref_type != 'branch') + steps: + - name: Checkout + if: env.PURE == 'false' + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Ignore Tags + if: github.event.ref_type != 'tag' && env.PURE == 'false' + run: git tag -d $(git tag --points-at HEAD) + + - name: Build Manylinux Wheels + if: env.PURE == 'false' + uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64 + with: + python-versions: ${{ matrix.python }} + + - name: Upload Artifact + if: env.PURE == 'false' + uses: actions/upload-artifact@v2 + with: + name: dist + path: wheelhouse/*manylinux*.whl + + release: + name: Release + runs-on: ubuntu-latest + needs: [build, manylinux] + steps: + + - name: Download Artifact + uses: actions/download-artifact@v2 + with: + name: dist + path: ./dist + + - name: Download Artifact + uses: actions/download-artifact@v2 + with: + name: conda_packages + path: ./conda_packages + + # - name: Publish on TestPyPI + # uses: pypa/gh-action-pypi-publish@master + # with: + # user: __token__ + # password: ${{ secrets.testpypi }} + # repository_url: https://test.pypi.org/legacy/ + - name: Get Version Number if: github.event.ref_type == 'tag' run: | VERSION="${GITHUB_REF/refs\/tags\/v/}" echo "::set-env name=VERSION::$VERSION" + - name: Create GitHub Release if: github.event.ref_type == 'tag' id: create_release @@ -63,6 +225,7 @@ jobs: release_name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} draft: true prerelease: ${{ contains(github.event.ref, 'rc') }} + - name: Upload Release Asset if: github.event.ref_type == 'tag' uses: actions/upload-release-asset@v1 @@ -73,9 +236,41 @@ jobs: asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz asset_content_type: application/gzip + - name: Publish on PyPI if: github.event.ref_type == 'tag' uses: pypa/gh-action-pypi-publish@master with: user: __token__ password: ${{ secrets.pypi }} + + - name: Install Miniconda and cloud client + run: | + curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + bash Miniconda3-latest-Linux-x86_64.sh -b -p .miniconda + source .miniconda/etc/profile.d/conda.sh + conda activate + conda install anaconda-client + + # - name: Publish to Anaconda test label + # if: github.event.ref_type != 'tag' + # run: | + # source .miniconda/etc/profile.d/conda.sh + # conda activate + # anaconda \ + # --token ${{ secrets.ANACONDA_API_TOKEN }} \ + # upload \ + # --user $ANACONDA_USER \ + # --label test \ + # conda_packages/*/* + + - name: Publish to Anaconda main label + if: github.event.ref_type == 'tag' + run: | + source .miniconda/etc/profile.d/conda.sh + conda activate + anaconda \ + --token ${{ secrets.ANACONDA_API_TOKEN }} \ + upload \ + --user $ANACONDA_USER \ + conda_packages/*/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e6ca9c7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "setuptools_scm"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index 0d844f8..96927db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,8 +30,3 @@ install_requires = numpy>=1.15 scipy matplotlib -setup_requires = - setuptools_scm - -[dist_conda] -pythons = 3.6, 3.7, 3.8 From 6d3b9665b73134496331f3d641136e245bd187e3 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Fri, 29 May 2020 18:38:47 -0400 Subject: [PATCH 2/2] Reset branches back to normal ready for merge --- .github/workflows/release.yml | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02ceb3a..0881315 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,9 +3,8 @@ name: Build and Release on: push: branches: - - conda - # - master - # - maintenance/* + - master + - maintenance/* create: tags: - 'v[0-9]+.[0-9]+.[0-9]+*' @@ -201,12 +200,12 @@ jobs: name: conda_packages path: ./conda_packages - # - name: Publish on TestPyPI - # uses: pypa/gh-action-pypi-publish@master - # with: - # user: __token__ - # password: ${{ secrets.testpypi }} - # repository_url: https://test.pypi.org/legacy/ + - name: Publish on TestPyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.testpypi }} + repository_url: https://test.pypi.org/legacy/ - name: Get Version Number if: github.event.ref_type == 'tag' @@ -252,17 +251,17 @@ jobs: conda activate conda install anaconda-client - # - name: Publish to Anaconda test label - # if: github.event.ref_type != 'tag' - # run: | - # source .miniconda/etc/profile.d/conda.sh - # conda activate - # anaconda \ - # --token ${{ secrets.ANACONDA_API_TOKEN }} \ - # upload \ - # --user $ANACONDA_USER \ - # --label test \ - # conda_packages/*/* + - name: Publish to Anaconda test label + if: github.event.ref_type != 'tag' + run: | + source .miniconda/etc/profile.d/conda.sh + conda activate + anaconda \ + --token ${{ secrets.ANACONDA_API_TOKEN }} \ + upload \ + --user $ANACONDA_USER \ + --label test \ + conda_packages/*/* - name: Publish to Anaconda main label if: github.event.ref_type == 'tag'