|
| 1 | +name: Build and upload to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + |
| 8 | +env: |
| 9 | + LIBZIM_DL_VERSION: "8.2.0" |
| 10 | + MACOSX_DEPLOYMENT_TARGET: "11.0" |
| 11 | + CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION" |
| 12 | + # APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step |
| 13 | + APPLE_SIGNING_KEYCHAIN_PROFILE: "build-profile" |
| 14 | + APPLE_SIGNING_IDENTITY: "${{ secrets.APPLE_SIGNING_IDENTITY }}" |
| 15 | + SIGN_APPLE: "yes" |
| 16 | + |
| 17 | + |
| 18 | +jobs: |
| 19 | + build_wheels: |
| 20 | + environment: release |
| 21 | + name: Build wheels on ${{ matrix.os }} |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + os: [ubuntu-20.04, macos-12] # macos-11, windows-2019 |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + |
| 30 | + - name: Set up QEMU |
| 31 | + if: runner.os == 'Linux' |
| 32 | + uses: docker/setup-qemu-action@v2 |
| 33 | + with: |
| 34 | + platforms: all |
| 35 | + |
| 36 | + - name: Prepare Apple Keychain for Signing |
| 37 | + if: matrix.os == 'macos-12' |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + # store certificate on filesystem |
| 41 | + export CERTIFICATE="$(mktemp -d)/wmch-devid.p12" |
| 42 | + echo "${{ secrets.APPLE_SIGNING_CERTIFICATE }}" | base64 --decode -o $CERTIFICATE |
| 43 | +
|
| 44 | + # create a dedicated keychain |
| 45 | + export APPLE_SIGNING_KEYCHAIN_PATH="$(mktemp -d)/build.keychain" |
| 46 | + echo "APPLE_SIGNING_KEYCHAIN_PATH=${APPLE_SIGNING_KEYCHAIN_PATH}" >> "$GITHUB_ENV" |
| 47 | + security create-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 48 | + security default-keychain -s ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 49 | + security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 50 | +
|
| 51 | + # import certificate into keychain then remove from filesystem |
| 52 | + security import ${CERTIFICATE} -k ${APPLE_SIGNING_KEYCHAIN_PATH} -P "${{ secrets.APPLE_SIGNING_P12_PASSWORD }}" -A |
| 53 | + rm $CERTIFICATE |
| 54 | +
|
| 55 | + # store signing credentials into the keychain |
| 56 | + security set-key-partition-list -S "apple-tool:,apple:" -s -k mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 57 | + security find-identity -v |
| 58 | + xcrun notarytool store-credentials \ |
| 59 | + --apple-id "${{ secrets.APPLE_SIGNING_ALTOOL_USERNAME }}" \ |
| 60 | + --password "${{ secrets.APPLE_SIGNING_ALTOOL_PASSWORD }}" \ |
| 61 | + --team-id "${{ secrets.APPLE_SIGNING_TEAM }}" \ |
| 62 | + --validate \ |
| 63 | + --keychain ${APPLE_SIGNING_KEYCHAIN_PATH} \ |
| 64 | + ${APPLE_SIGNING_KEYCHAIN_PROFILE} |
| 65 | +
|
| 66 | + # disable auto-locking of keychain |
| 67 | + security set-keychain-settings ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 68 | + security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 69 | +
|
| 70 | + - name: Build wheels |
| 71 | + uses: pypa/cibuildwheel@v2.12.1 |
| 72 | + |
| 73 | + - name: Cleanup Apple Keychain |
| 74 | + if: matrix.os == 'macos-12' |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + security lock-keychain ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 78 | + security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 79 | + rm -f ${APPLE_SIGNING_KEYCHAIN_PATH} |
| 80 | +
|
| 81 | + - uses: actions/upload-artifact@v3 |
| 82 | + with: |
| 83 | + path: ./wheelhouse/*.whl |
| 84 | + |
| 85 | + build_sdist: |
| 86 | + name: Build source distribution |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v3 |
| 90 | + |
| 91 | + - name: Build sdist |
| 92 | + run: pipx run build --sdist |
| 93 | + |
| 94 | + - uses: actions/upload-artifact@v3 |
| 95 | + with: |
| 96 | + path: dist/*.tar.gz |
| 97 | + |
| 98 | + upload_pypi: |
| 99 | + needs: [build_wheels, build_sdist] |
| 100 | + runs-on: ubuntu-latest |
| 101 | + environment: release |
| 102 | + steps: |
| 103 | + - uses: actions/download-artifact@v3 |
| 104 | + with: |
| 105 | + # unpacks default artifact into dist/ |
| 106 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 107 | + name: artifact |
| 108 | + path: dist |
| 109 | + |
| 110 | + - uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 111 | + with: |
| 112 | + user: __token__ |
| 113 | + # password: ${{ secrets.PYPI_TEST_API_TOKEN }} |
| 114 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 115 | + # uncomment for test |
| 116 | + # repository_url: https://test.pypi.org/legacy/ |
0 commit comments