rgb-lib-release #18
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 and Release | |
| on: | |
| # Trigger from rgb-lib repository | |
| repository_dispatch: | |
| types: [rgb-lib-release] | |
| # Manual trigger | |
| workflow_dispatch: | |
| inputs: | |
| rgb_lib_version: | |
| description: 'rgb-lib version to use (e.g., v0.3.0-beta.8)' | |
| required: true | |
| type: string | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.platform }}) | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x64 (Ubuntu 22.04 for GLIBC 2.35 compatibility) | |
| - runner: ubuntu-22.04 | |
| platform: linux-x86_64 | |
| target: x86_64-unknown-linux-gnu | |
| # Linux ARM64 (Ubuntu 22.04 for GLIBC 2.35 compatibility) | |
| - runner: ubuntu-22.04-arm | |
| platform: linux-aarch64 | |
| target: aarch64-unknown-linux-gnu | |
| # macOS ARM64 (Apple Silicon) | |
| - runner: macos-latest | |
| platform: macosx-arm64 | |
| target: aarch64-apple-darwin | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Get rgb-lib version | |
| id: rgb_lib_version | |
| run: | | |
| if [ "${{ github.event_name }}" == "repository_dispatch" ]; then | |
| echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT | |
| elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "version=${{ inputs.rgb_lib_version }}" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| - name: Update rgb-lib submodule to target version | |
| run: | | |
| cd rgb-lib | |
| git fetch --all --tags | |
| git checkout ${{ steps.rgb_lib_version.outputs.version }} | |
| echo "Checked out rgb-lib version:" | |
| git log --oneline -1 | |
| cd .. | |
| shell: bash | |
| - name: Get version for Python package | |
| id: pyversion | |
| run: | | |
| VERSION="${{ steps.rgb_lib_version.outputs.version }}" | |
| # Remove 'v' prefix and convert to PEP 440 format | |
| # v0.3.0-beta.8 -> 0.3.0b8 | |
| PY_VERSION=$(echo "$VERSION" | sed 's/^v//' | sed 's/-beta\./b/' | sed 's/-alpha\./a/' | sed 's/-rc\./rc/') | |
| echo "version=$PY_VERSION" >> $GITHUB_OUTPUT | |
| echo "Python version: $PY_VERSION" | |
| - name: Update version in pyproject.toml | |
| run: | | |
| VERSION="${{ steps.pyversion.outputs.version }}" | |
| sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml | |
| cat pyproject.toml | grep "^version" | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install poetry | |
| - name: Build wheel | |
| run: | | |
| export PLATFORM="${{ matrix.platform }}" | |
| echo "Building for platform: $PLATFORM" | |
| poetry build -vvv | |
| env: | |
| PLATFORM: ${{ matrix.platform }} | |
| - name: List built wheels | |
| run: ls -la dist/ || echo "dist/ not found, checking current directory..." && ls -la | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.platform }} | |
| path: dist/*.whl | |
| retention-days: 5 | |
| publish: | |
| name: Publish to PyPI | |
| needs: build | |
| if: always() && !cancelled() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: wheels | |
| pattern: wheel-* | |
| merge-multiple: true | |
| - name: List wheels | |
| run: ls -la wheels/ | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install twine | |
| run: pip install twine | |
| - name: Publish to PyPI | |
| run: | | |
| twine upload wheels/*.whl --skip-existing || echo "Some packages may already exist, continuing..." | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| release: | |
| name: Create GitHub Release | |
| needs: [build, publish] | |
| if: always() && !cancelled() | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get version info | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" == "repository_dispatch" ]; then | |
| VERSION="${{ github.event.client_payload.version }}" | |
| else | |
| VERSION="${{ inputs.rgb_lib_version }}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Download all wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: wheels | |
| pattern: wheel-* | |
| merge-multiple: true | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.version }} | |
| name: Release ${{ steps.version.outputs.version }} | |
| body: | | |
| ## Python bindings for rgb-lib | |
| Based on rgb-lib ${{ steps.version.outputs.version }} | |
| ### Installation via pip (recommended) | |
| ```bash | |
| pip install rgb-lib | |
| ``` | |
| ### Platforms | |
| | Platform | Wheel | | |
| |----------|-------| | |
| | Linux x64 | `manylinux_2_34_x86_64` | | |
| | Linux ARM64 | `manylinux_2_34_aarch64` | | |
| | macOS ARM64 (Apple Silicon) | `macosx_12_0_arm64` | | |
| ### Changes | |
| See [rgb-lib release notes](https://github.com/UTEXO-Protocol/rgb-lib/releases/tag/${{ steps.version.outputs.version }}) | |
| draft: false | |
| prerelease: ${{ contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'rc') }} | |
| files: wheels/*.whl | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |