build (bcrypt) #330
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 (bcrypt) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| default: 'latest' | |
| description: 'Package version' | |
| type: string | |
| required: true | |
| schedule: | |
| - cron: '0 15 * * *' | |
| jobs: | |
| manylinux: | |
| runs-on: ${{ matrix.MANYLINUX.RUNNER }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| PYTHON: | |
| - { VERSION: "cp38", ABI_VERSION: 'cp38' } | |
| - { VERSION: "cp39", ABI_VERSION: 'cp39' } | |
| MANYLINUX: | |
| - { NAME: "manylinux_2_38_loongarch64", CONTAINER: "cryptography-manylinux_2_38:loongarch64", RUNNER: "ubuntu-24.04" } | |
| - { NAME: "musllinux_1_2_loongarch64", CONTAINER: "cryptography-musllinux_1_2:loongarch64", RUNNER: "ubuntu-24.04" } | |
| steps: | |
| - name: Get Source Code | |
| run: | | |
| package=bcrypt | |
| if [ "${{ github.event_name }}" = "schedule" ]; then | |
| version="latest" | |
| else | |
| version=${{ github.event.inputs.version }} | |
| fi | |
| if [ "$version" = "latest" ]; then | |
| version=$(curl -sSL "https://pypi.org/pypi/${package}/json" | jq -r '.info.version') | |
| fi | |
| echo "Building package: ${package} version: ${version}" | |
| echo "PIP_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/65746188/packages/pypi/simple" >> $GITHUB_ENV | |
| case "${{ matrix.MANYLINUX.NAME }}" in | |
| manylinux_2_38_loongarch64) | |
| check_file="${package}-${version}-.*manylinux_2_38_loongarch64.whl" | |
| echo "CIBW_ARCHS=loongarch64" >> $GITHUB_ENV | |
| echo "CIBW_BUILD=${{ matrix.PYTHON.VERSION }}-manylinux_loongarch64" >> $GITHUB_ENV | |
| echo "CIBW_MANYLINUX_LOONGARCH64_IMAGE=ghcr.io/loong64/${{ matrix.MANYLINUX.CONTAINER }}" >> $GITHUB_ENV | |
| ;; | |
| musllinux_1_2_loongarch64) | |
| check_file="${package}-${version}-.*musllinux_1_2_loongarch64.whl" | |
| echo "CIBW_ARCHS=loongarch64" >> $GITHUB_ENV | |
| echo "CIBW_BUILD=${{ matrix.PYTHON.VERSION }}-musllinux_loongarch64" >> $GITHUB_ENV | |
| echo "CIBW_MUSLLINUX_LOONGARCH64_IMAGE=ghcr.io/loong64/${{ matrix.MANYLINUX.CONTAINER }}" >> $GITHUB_ENV | |
| ;; | |
| *) | |
| echo "BUILD=false" >> $GITHUB_ENV | |
| exit 0 | |
| ;; | |
| esac | |
| if curl "https://gitlab.com/api/v4/projects/65746188/packages/pypi/simple/${package/./-}" | grep -oP '(?<=>)[^<]+\.whl' | grep -q "${check_file}"; then | |
| echo "Package ${package} ${version} already exists" | |
| echo "BUILD=false" >> $GITHUB_ENV | |
| exit 0 | |
| fi | |
| full_json=$(curl -sSL "https://pypi.org/pypi/${package}/${version}/json") | |
| download_url=$(echo "$full_json" | jq -r '.urls[] | select(.packagetype=="sdist").url') | |
| if [ -z "$download_url" ]; then | |
| echo "No source found for package ${package} version ${version}" | |
| exit 1 | |
| fi | |
| wget -O - "$download_url" | tar xz --strip-components=1 | |
| - name: Setup QEMU | |
| if: env.BUILD != 'false' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Build wheels | |
| if: env.BUILD != 'false' | |
| uses: loong64/cibuildwheel@v3.2.1 | |
| env: | |
| CIBW_BUILD_FRONTEND: "pip; args: --config-settings=--build-option=--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}" | |
| CIBW_ENVIRONMENT_LINUX: > | |
| RUSTUP_HOME="/root/.rustup" | |
| CIBW_ENVIRONMENT_PASS_LINUX: PIP_EXTRA_INDEX_URL RUNNER_ARCH | |
| - name: Check wheel | |
| run: | | |
| ls -al wheelhouse/*.whl || exit 0 | |
| echo "upload=true" >> $GITHUB_ENV | |
| - name: Upload wheels | |
| if: env.upload == 'true' | |
| run: | | |
| pip install twine==6.0.1 | |
| for file in wheelhouse/*.whl; do | |
| twine upload --repository-url https://gitlab.com/api/v4/projects/65746188/packages/pypi $file || true | |
| done | |
| env: | |
| TWINE_USERNAME: ${{ github.repository_owner }} | |
| TWINE_PASSWORD: ${{ secrets.GL_TOKEN }} |