mirror of
https://github.com/roapi/roapi.git
synced 2026-06-11 21:00:56 +08:00
213 lines
7.7 KiB
YAML
213 lines
7.7 KiB
YAML
name: roapi-http release
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
tags: [ 'roapi-http-v*' ]
|
|
|
|
env:
|
|
# NOTE: this env is also defined in build.yml
|
|
RUST_TC_NIGHTLY_VER: "2021-07-17"
|
|
|
|
jobs:
|
|
validate-release-tag:
|
|
name: Validate git tag
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
if: "startsWith(github.ref, 'refs/tags/')"
|
|
- name: compare git tag with cargo metadata
|
|
if: "startsWith(github.ref, 'refs/tags/')"
|
|
run: |
|
|
PUSHED_TAG=${GITHUB_REF##*/}
|
|
CURR_VER=$( grep version roapi-http/Cargo.toml | head -n 1 | awk '{print $3}' | tr -d '"' )
|
|
if [[ "${PUSHED_TAG}" != "roapi-http-v${CURR_VER}" ]]; then
|
|
echo "Cargo metadata has version set to ${CURR_VER}, but got pushed tag ${PUSHED_TAG}."
|
|
exit 1
|
|
fi
|
|
- name: skip git tag validation
|
|
if: "! startsWith(github.ref, 'refs/tags/')"
|
|
run: echo "skip tag version validation on non-release branch run"
|
|
|
|
macos:
|
|
needs: validate-release-tag
|
|
runs-on: macos-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-python@v2
|
|
with:
|
|
python-version: 3.6
|
|
- name: Install Rust toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: nightly-${{ env.RUST_TC_NIGHTLY_VER }}
|
|
target: aarch64-apple-darwin
|
|
profile: minimal
|
|
default: true
|
|
- name: Install maturin
|
|
run: pip3 install 'maturin<0.12'
|
|
- name: Build wheels - x86_64
|
|
run: |
|
|
maturin build -m roapi-http/Cargo.toml -b bin --target x86_64-apple-darwin --release --out dist --cargo-extra-args="--features=simd"
|
|
pip install roapi-http --no-index --find-links dist --force-reinstall
|
|
- name: Build wheels - universal2
|
|
env:
|
|
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
|
|
MACOSX_DEPLOYMENT_TARGET: '10.9'
|
|
run: |
|
|
# set SDKROOT for C dependencies
|
|
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
|
|
maturin build -m roapi-http/Cargo.toml -b bin --release --universal2 --out dist --no-sdist --cargo-extra-args="--features=simd"
|
|
pip install roapi-http --no-index --find-links dist --force-reinstall
|
|
- name: Upload wheels
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: wheels
|
|
path: dist
|
|
- name: Archive binary
|
|
run: tar czvf target/release/roapi-http.tar.gz -C target/release roapi-http
|
|
- name: Upload binary to GitHub Release
|
|
uses: svenstaro/upload-release-action@v2
|
|
if: "startsWith(github.ref, 'refs/tags/')"
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
asset_name: roapi-http-apple-darwin.tar.gz
|
|
file: target/release/roapi-http.tar.gz
|
|
tag: ${{ github.ref }}
|
|
|
|
windows:
|
|
needs: validate-release-tag
|
|
runs-on: windows-latest
|
|
strategy:
|
|
matrix:
|
|
platform: [
|
|
{ python-architecture: "x64", target: "x86_64-pc-windows-msvc", features: "simd" },
|
|
{ python-architecture: "x86", target: "i686-pc-windows-msvc", features: "" },
|
|
]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-python@v2
|
|
with:
|
|
python-version: 3.6
|
|
architecture: ${{ matrix.platform.python-architecture }}
|
|
- name: Install Rust toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: nightly-${{ env.RUST_TC_NIGHTLY_VER }}
|
|
target: ${{ matrix.platform.target }}
|
|
profile: minimal
|
|
default: true
|
|
- name: Install maturin
|
|
run: pip3 install 'maturin<0.12'
|
|
- name: Build wheels
|
|
run: |
|
|
maturin build -m roapi-http/Cargo.toml -b bin --release --out dist --no-sdist --target ${{ matrix.platform.target }} --cargo-extra-args="--features=${{ matrix.platform.features }}"
|
|
pip install roapi-http --no-index --find-links dist --force-reinstall
|
|
roapi-http --help
|
|
- name: Upload wheels
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: wheels
|
|
path: dist
|
|
|
|
linux:
|
|
needs: validate-release-tag
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
platform: [
|
|
{ manylinux: '2010', target: "x86_64-unknown-linux-musl", image_tag: "x86_64-musl", features: "simd" },
|
|
{ manylinux: '2010', target: "i686-unknown-linux-musl", image_tag: "i686-musl", features: "" },
|
|
{ manylinux: '2014', target: "aarch64-unknown-linux-musl", image_tag: "aarch64-musl", features: "" },
|
|
{ manylinux: '2014', target: "armv7-unknown-linux-musleabihf", image_tag: "armv7-musleabihf", features: "" },
|
|
]
|
|
container:
|
|
image: docker://benfred/rust-musl-cross:${{ matrix.platform.image_tag }}
|
|
env:
|
|
RUSTUP_HOME: /root/.rustup
|
|
CARGO_HOME: /root/.cargo
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install Rust toolchain
|
|
run: |
|
|
rustup update nightly-${{ env.RUST_TC_NIGHTLY_VER }}
|
|
rustup target add \
|
|
--toolchain nightly-${{ env.RUST_TC_NIGHTLY_VER }} \
|
|
${{ matrix.platform.target }}
|
|
rustup default nightly-${{ env.RUST_TC_NIGHTLY_VER }}
|
|
- name: Build Wheels
|
|
run: |
|
|
pip3 install 'maturin<0.12'
|
|
maturin build -m roapi-http/Cargo.toml -b bin --no-sdist --release -o dist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} --cargo-extra-args="--features=${{ matrix.platform.features }}"
|
|
- name: Upload wheels
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: wheels
|
|
path: dist
|
|
- name: Archive binary
|
|
run: tar czvf target/release/roapi-http.tar.gz -C target/${{ matrix.platform.target }}/release roapi-http
|
|
- name: Upload binary to GitHub Release
|
|
uses: svenstaro/upload-release-action@v2
|
|
if: "startsWith(github.ref, 'refs/tags/')"
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
asset_name: roapi-http-${{ matrix.platform.target }}.tar.gz
|
|
file: target/release/roapi-http.tar.gz
|
|
tag: ${{ github.ref }}
|
|
|
|
pypi_release:
|
|
needs: [ validate-release-tag, linux, macos, windows ]
|
|
name: PyPI Release
|
|
runs-on: ubuntu-latest
|
|
if: "startsWith(github.ref, 'refs/tags/')"
|
|
steps:
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: wheels
|
|
- uses: actions/setup-python@v2
|
|
with:
|
|
python-version: 3.9
|
|
- name: Publish to PyPi
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
|
run: |
|
|
pip install --upgrade twine
|
|
twine upload --skip-existing *
|
|
|
|
docker_release:
|
|
if: "startsWith(github.ref, 'refs/tags/')"
|
|
needs: validate-release-tag
|
|
name: Docker Image Release
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
|
with:
|
|
flavor: |
|
|
latest=true
|
|
tags: |
|
|
type=match,pattern=roapi-http-(v.+),group=1
|
|
images: ghcr.io/${{ github.repository_owner }}/roapi-http
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|