From 7c0c20a8f78b29834dcd4edeb7df381e5a8a92a3 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 6 Oct 2021 13:44:20 +1000 Subject: [PATCH] Convert GitHub actions to YAML, adjust release Converts the existing GitHub action files to YAML to reduce some of the quotes, lines, and support comments. Changes the release process to build the sdist first and then the wheels are built from that sdist. Also adds macOS wheels to the publishing process. Signed-off-by: Jordan Borean --- .github/stale.yml | 14 +- .github/workflows/build.yml | 222 +++++++++------------ .github/workflows/deploy-docs.yml | 54 +++-- .github/workflows/release.yml | 317 ++++++++++++++++-------------- ci/release-win.sh | 43 ---- 5 files changed, 295 insertions(+), 355 deletions(-) delete mode 100755 ci/release-win.sh diff --git a/.github/stale.yml b/.github/stale.yml index ec0dcc5c..a11e868f 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,7 +1,7 @@ -{ - "daysUntilStale": 28, - "daysUntilClose": 14, - "staleLabel": "stale", - "markComment": false, - "only": "pulls", -} +# TODO: This is marked as deprecated - migrate to https://github.com/actions/stale +# https://github.com/marketplace/actions/stale-for-actions +daysUntilStale: 28 +daysUntilClose: 14 +staleLabel: stale +markComment: 'false' +only: pulls diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5085af1..61500dfe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,135 +1,93 @@ -{ - "name": "Build", - "on": { - "push": { - "branches-ignore": "gh-pages", - "tags-ignore": "*", - }, - "pull_request": null, - }, +name: Build +on: + push: + branches-ignore: gh-pages + tags-ignore: '*' + pull_request: null - "jobs": { - "linux": { - "runs-on": "ubuntu-latest", - "strategy": { - "fail-fast": false, - "matrix": { - "name": ["debian-stable", "debian-heimdal", "centos-8", - "fedora-latest"], - "include": [ - { - "name": "debian-stable", - "distro": "debian:stable", - }, - { - "name": "debian-heimdal", - "distro": "debian:stable", - "krb5_ver": "heimdal", - }, - { - "name": "centos-8", - "distro": "centos:8", - }, - { - "name": "fedora-latest", - "distro": "fedora:latest", - "flake": "yes", - }, - ], - }, - }, - "steps": [ - { - "name": "Check out code", - "uses": "actions/checkout@v2", - }, - { - "name": "Build and test gssapi", - "run": "./ci/run-on-linux.sh ./ci/build.sh", - "env": { - "DISTRO": "${{ matrix.distro }}", - "KRB5_VER": "${{ matrix.krb5_ver }}", - "FLAKE": "${{ matrix.flake }}", - }, - }, - ], - }, +jobs: + linux: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + name: + - debian-stable + - debian-heimdal + - centos-8 + - fedora-latest + include: + - name: debian-stable + distro: debian:stable + - name: debian-heimdal + distro: debian:stable + krb5_ver: heimdal + - name: centos-8 + distro: centos:8 + - name: fedora-latest + distro: fedora:latest + flake: 'yes' - "windows": { - "runs-on": "windows-latest", - "strategy": { - "fail-fast": false, - "matrix": { - "name": [ - "win-py-3.10", - "win-py-3.9", - "win-py-3.8", - "win-py-3.7", - "win-py-3.6", - ], - "arch": [ - "x64", - "x86" - ], - "include": [ - { - "name": "win-py-3.10", - "pyenv": "3.10", - }, - { - "name": "win-py-3.9", - "pyenv": "3.9", - }, - { - "name": "win-py-3.8", - "pyenv": "3.8", - }, - { - "name": "win-py-3.7", - "pyenv": "3.7", - }, - { - "name": "win-py-3.6", - "pyenv": "3.6", - }, - ], - }, - }, - "steps": [ - { - "name": "Check out code", - "uses": "actions/checkout@v2", - }, - { - "name": "Install the right python", - "uses": "actions/setup-python@v2", - "with": { - "python-version": "${{ matrix.pyenv }}", - "architecture": "${{ matrix.arch }}" - }, - }, - { - "name": "Build and test gssapi", - "shell": "bash", - "run": "./ci/build.sh", - "env": { "OS_NAME": "windows" }, - }, - ], - }, + steps: + - name: Check out code + uses: actions/checkout@v2 - "macos-heimdal": { - "runs-on": "macos-latest", - "steps": [ - { - "name": "Check out code", - "uses": "actions/checkout@v2", - }, - { - "name": "Build and test gssapi", - "run": "./ci/build.sh", - "env": { "KRB5_VER": "heimdal" }, - }, - ], - }, - }, -} + - name: Build and test gssapi + run: ./ci/run-on-linux.sh ./ci/build.sh + env: + DISTRO: ${{ matrix.distro }} + KRB5_VER: ${{ matrix.krb5_ver }} + FLAKE: ${{ matrix.flake }} + + windows: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + name: + - win-py-3.10 + - win-py-3.9 + - win-py-3.8 + - win-py-3.7 + - win-py-3.6 + arch: + - x64 + - x86 + include: + - name: win-py-3.10 + pyenv: '3.10' + - name: win-py-3.9 + pyenv: '3.9' + - name: win-py-3.8 + pyenv: '3.8' + - name: win-py-3.7 + pyenv: '3.7' + - name: win-py-3.6 + pyenv: '3.6' + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Install the right python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.pyenv }} + architecture: ${{ matrix.arch }} + + - name: Build and test gssapi + shell: bash + run: ./ci/build.sh + env: + OS_NAME: windows + + macos-heimdal: + runs-on: macos-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Build and test gssapi + run: ./ci/build.sh + env: + KRB5_VER: heimdal diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index df17abac..32021ce5 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,30 +1,24 @@ -{ - "name": "Deploy docs", - "on": { "push": { "branches": "main" }}, - "jobs": { - "update-pages": { - "runs-on": "ubuntu-latest", - "steps": [ - { - "name": "Check out code", - "uses": "actions/checkout@v2", - }, - { - "name": "Build docs", - "env": { "DISTRO": "fedora:latest" }, - "run": "./ci/run-on-linux.sh ./ci/before-docs-deploy.sh", - }, - { - "name": "Deploy latest docs", - "uses": "JamesIves/github-pages-deploy-action@3.7.1", - "with": { - "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}", - "BRANCH": "gh-pages", - "FOLDER": "ci_docs_build/html", - "TARGET_FOLDER": "latest", - }, - }, - ], - }, - }, -} +name: Deploy docs +on: + push: + branches: main + +jobs: + update-pages: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Build docs + run: ./ci/run-on-linux.sh ./ci/before-docs-deploy.sh + env: + DISTRO: fedora:latest + + - name: Deploy latest docs + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: ci_docs_build/html + TARGET_FOLDER: latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c299e02f..226253a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,143 +1,174 @@ -{ - "name": "Release", - "on": { "push": { "tags": "v*" }}, - "jobs": { - "release-linux": { - "runs-on": "ubuntu-latest", - "steps": [ - { - "name": "Check out code", - "uses": "actions/checkout@v2", - }, - { - "name": "Set things up", - "env": { "DISTRO": "fedora:latest" }, - "run": "./ci/run-on-linux.sh ./ci/before-deploy.sh", - }, - { - "name": "Deploy to PyPI", - "uses": "pypa/gh-action-pypi-publish@v1.1.0", - "with": { - "user": "__token__", - "password": "${{ secrets.pypi_password }}", - }, - }, - { - "name": "Deploy stable docs", - "uses": "JamesIves/github-pages-deploy-action@3.7.1", - "with": { - "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}", - "BRANCH": "gh-pages", - "FOLDER": "ci_docs_build/html", - "TARGET_FOLDER": "stable", - }, - }, - { - "name": "Create release", - "uses": "actions/create-release@v1", - "id": "cr", - "env": { "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}" }, - "with": { - "tag_name": "${{ github.ref }}", - "release_name": "${{ github.ref }}", - }, - }, - { - "id": "tarball", - "run": "echo \"::set-output name=tarball::`ls tag_build/*.tar.gz | awk -F/ '{print $2}'`\"" - }, - { - "id": "checksum", - "run": "echo \"::set-output name=checksum::`ls tag_build/*.sha512sum | awk -F/ '{print $2}'`\"" - }, - { - "name": "Upload release tarball", - "uses": "actions/upload-release-asset@v1", - "env": { "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}" }, - "with": { - "upload_url": "${{ steps.cr.outputs.upload_url }}", - "asset_path": "tag_build/${{ steps.tarball.outputs.tarball }}", - "asset_name": "${{ steps.tarball.outputs.tarball }}", - "asset_content_type": "application/octet-stream", - }, - }, - { - "name": "Upload release checksum", - "uses": "actions/upload-release-asset@v1", - "env": { "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}" }, - "with": { - "upload_url": "${{ steps.cr.outputs.upload_url }}", - "asset_path": "tag_build/${{ steps.checksum.outputs.checksum }}", - "asset_name": "${{ steps.checksum.outputs.checksum }}", - "asset_content_type": "text/plain", - }, - }, - ], - }, - - "release-windows": { - "runs-on": "windows-latest", - "strategy": { - "matrix": { - "name": [ - "win-wheel-3.10", - "win-wheel-3.9", - "win-wheel-3.8", - "win-wheel-3.7", - "win-wheel-3.6", - ], - "arch": [ - "x64", - "x86" - ], - "include": [ - { - "name": "win-wheel-3.10", - "pyenv": "3.10", - }, - { - "name": "win-wheel-3.9", - "pyenv": "3.9", - }, - { - "name": "win-wheel-3.8", - "pyenv": "3.8", - }, - { - "name": "win-wheel-3.7", - "pyenv": "3.7", - }, - { - "name": "win-wheel-3.6", - "pyenv": "3.6", - }, - ], - }, - }, - "steps": [ - { - "name": "Check out code", - "uses": "actions/checkout@v2", - }, - { - "name": "Install the right python", - "uses": "actions/setup-python@v2", - "with": { - "python-version": "${{ matrix.pyenv }}", - "architecture": "${{ matrix.arch }}" - }, - }, - { - "name": "Create and upload Windows wheel", - "shell": "bash", - "run": "./ci/release-win.sh", - "env": { - "OS_NAME": "windows", - "TWINE_USER": "__token__", - "TWINE_PASSWORD": "${{ secrets.pypi_password }}", - }, - }, - ], - }, - }, -} +name: Release +on: + push: + tags: v* + +jobs: + sdist-release: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set things up + run: ./ci/run-on-linux.sh ./ci/before-deploy.sh + env: + DISTRO: fedora:latest + + - name: Upload sdist + uses: actions/upload-artifact@v2 + with: + path: ./dist/*.tar.gz + name: artifact + + - name: Deploy stable docs + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: ci_docs_build/html + TARGET_FOLDER: stable + + - name: Create release + uses: actions/create-release@v1 + id: cr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + + - id: tarball + run: echo "::set-output name=tarball::`ls tag_build/*.tar.gz | awk -F/ '{print $2}'`" + + - id: checksum + run: echo "::set-output name=checksum::`ls tag_build/*.sha512sum | awk -F/ '{print $2}'`" + + - name: Upload release tarball + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.cr.outputs.upload_url }} + asset_path: tag_build/${{ steps.tarball.outputs.tarball }} + asset_name: ${{ steps.tarball.outputs.tarball }} + asset_content_type: application/octet-stream + + - name: Upload release checksum + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.cr.outputs.upload_url }} + asset_path: tag_build/${{ steps.checksum.outputs.checksum }} + asset_name: ${{ steps.checksum.outputs.checksum }} + asset_content_type: text/plain + + wheel: + needs: + - sdist-release + + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: macOS-10.15 + version: cp310-macosx_x86_64 + - os: macOS-10.15 + version: cp310-macosx_arm64 + - os: macOS-10.15 + version: cp39-macosx_x86_64 + - os: macOS-10.15 + version: cp39-macosx_arm64 + - os: macOS-10.15 + version: cp38-macosx_x86_64 + - os: macOS-10.15 + version: cp38-macosx_arm64 + - os: macOS-10.15 + version: cp37-macosx_x86_64 + - os: macOS-10.15 + version: cp36-macosx_x86_64 + + - os: windows-2019 + version: cp310-win_amd64 + - os: windows-2019 + version: cp310-win32 + - os: windows-2019 + version: cp39-win_amd64 + - os: windows-2019 + version: cp39-win32 + - os: windows-2019 + version: cp38-win_amd64 + - os: windows-2019 + version: cp38-win32 + - os: windows-2019 + version: cp37-win_amd64 + - os: windows-2019 + version: cp37-win32 + - os: windows-2019 + version: cp36-win_amd64 + - os: windows-2019 + version: cp36-win32 + + steps: + - name: Set up environment + if: startsWith(matrix.os, 'windows-') + shell: bash + run: | + choco.exe install \ + --no-progress \ + --yes \ + --ignore-detected-reboot \ + --allow-downgrade \ + --install-arguments "'ADDLOCAL=ALL'" \ + ${{ endsWith(matrix.version, '-win32') && '--x86' || '' }} mitkerberos || true + + echo "C:\Program Files${{ endsWith(matrix.version, '-win32') && ' (x86)' || '' }}\MIT\Kerberos\bin;$PATH" >> $GITHUB_PATH + + - name: Download sdist + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./ + + - name: Extract sdist + shell: bash + run: | + tar xf gssapi-*.tar.gz + mv gssapi-*/* . + rm -r gssapi-*/ + rm gssapi-*.tar.gz + + - name: Build wheel + uses: pypa/cibuildwheel@v2.1.2 + env: + CIBW_ARCHS: all + CIBW_TEST_SKIP: '*_arm64' + CIBW_BUILD: ${{ matrix.version }} + CIBW_BUILD_VERBOSITY: 1 + + - name: Upload wheel + uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl + name: artifact + + pypi: + needs: + - wheel + + runs-on: ubuntu-latest + + steps: + - name: Download sdist and wheels + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./dist + + - name: Deploy to PyPI + uses: pypa/gh-action-pypi-publish@v1.1.0 + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/ci/release-win.sh b/ci/release-win.sh deleted file mode 100755 index 925dc3c3..00000000 --- a/ci/release-win.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -e - -source ./ci/build.sh - -# build the wheel -python -m pip install wheel -python setup.py bdist_wheel - -cd dist - -tag=$(git describe --tags) - -# Rename and checksum the wheel -if [ x"${tag#v[0-9]}" = "x${tag}" ]; then - PYTHON_GSSAPI_VERSION=${tag} -else - PYTHON_GSSAPI_VERSION=${tag#v} -fi - -PKG_NAME_VER=$(ls *.whl | sed "s/gssapi-[^-]*-\(.*\)\.whl/python-gssapi-${PYTHON_GSSAPI_VERSION}-\1/") - -cp *.whl "${PKG_NAME_VER}.whl" - -sha512sum --binary ./${PKG_NAME_VER}.whl > ./${PKG_NAME_VER}.sha512sum - -cd .. - -# Hack around https://github.com/pypa/gh-action-pypi-publish/issues/32 - -echo 'Running: python -m pip install twine ...' -python -m pip install twine - -echo 'Running: set +x; python -m twine upload...' -# Please note this cannot be set -x or passwords will leak! -set +x - -python -m twine upload -u $TWINE_USER -p $TWINE_PASSWORD dist/gssapi* > out.log 2>&1 || true - -# and restore... -set -x -egrep -i 'fail|error' out.log && cat out.log && exit 1 - -exit 0