Fix OpenSSL for cross builds via pre-build deps and OPENSSL_VENDORED #12
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-release: | |
| name: Create release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Verify tag matches Cargo.toml version | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') | |
| if [ "$TAG" != "$CARGO_VERSION" ]; then | |
| echo "::error::Tag $GITHUB_REF_NAME does not match Cargo.toml version $CARGO_VERSION" | |
| exit 1 | |
| fi | |
| - name: Create draft release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "$GITHUB_REF_NAME" \ | |
| --draft \ | |
| --title "$GITHUB_REF_NAME" \ | |
| --generate-notes | |
| build-release: | |
| name: Build (${{ matrix.target }}) | |
| needs: create-release | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| include: | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| use_cross: true | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| use_cross: true | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust toolchain | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Install cross | |
| if: matrix.use_cross | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cross | |
| - name: Build | |
| shell: bash | |
| env: | |
| OPENSSL_VENDORED: "1" | |
| run: | | |
| if [ "${{ matrix.use_cross }}" = "true" ]; then | |
| cross build --release --target ${{ matrix.target }} | |
| else | |
| cargo build --release --target ${{ matrix.target }} | |
| fi | |
| - name: Package and checksum | |
| id: package | |
| shell: bash | |
| run: | | |
| BIN="serpapi" | |
| TARGET="${{ matrix.target }}" | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| PKG="${BIN}-${VERSION}-${TARGET}" | |
| mkdir "$PKG" | |
| cp README.md LICENSE "$PKG/" | |
| if [[ "$TARGET" == *"windows"* ]]; then | |
| cp "target/${TARGET}/release/${BIN}.exe" "$PKG/" | |
| 7z a "${PKG}.zip" "$PKG" | |
| ARCHIVE="${PKG}.zip" | |
| else | |
| cp "target/${TARGET}/release/${BIN}" "$PKG/" | |
| tar czf "${PKG}.tar.gz" "$PKG" | |
| ARCHIVE="${PKG}.tar.gz" | |
| fi | |
| sha256sum "$ARCHIVE" > "${ARCHIVE}.sha256" | |
| echo "archive=$ARCHIVE" >> "$GITHUB_OUTPUT" | |
| echo "sha256=${ARCHIVE}.sha256" >> "$GITHUB_OUTPUT" | |
| - name: Upload to release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload "$GITHUB_REF_NAME" \ | |
| "${{ steps.package.outputs.archive }}" \ | |
| "${{ steps.package.outputs.sha256 }}" |