Browse Source

ci: support more platforms

pull/76/head
sigoden 3 years ago
parent
commit
e6b7b79d96
  1. 57
      .github/workflows/release.yaml
  2. 24
      Dockerfile

57
.github/workflows/release.yaml

@ -13,12 +13,6 @@ jobs: @@ -13,12 +13,6 @@ jobs:
strategy:
matrix:
target:
- aarch64-unknown-linux-musl
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-musl
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
@ -26,6 +20,12 @@ jobs: @@ -26,6 +20,12 @@ jobs:
- target: aarch64-apple-darwin
os: macos-latest
use-cross: true
- target: aarch64-pc-windows-msvc
os: windows-latest
use-cross: true
- target: aarch64-linux-android
os: ubuntu-latest
use-cross: true
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
@ -33,7 +33,30 @@ jobs: @@ -33,7 +33,30 @@ jobs:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
- target: i686-unknown-linux-musl
os: ubuntu-latest
use-cross: true
- target: i686-pc-windows-msvc
os: windows-latest
use-cross: true
- target: armv7-unknown-linux-musleabihf
os: ubuntu-latest
use-cross: true
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
use-cross: true
- target: mips-unknown-linux-musl
os: ubuntu-latest
use-cross: true
- target: mipsel-unknown-linux-musl
os: ubuntu-latest
use-cross: true
- target: mips64-unknown-linux-gnuabi64
os: ubuntu-latest
use-cross: true
- target: mips64el-unknown-linux-gnuabi64
os: ubuntu-latest
use-cross: true
runs-on: ${{matrix.os}}
steps:
@ -59,14 +82,7 @@ jobs: @@ -59,14 +82,7 @@ jobs:
target: ${{ matrix.target }}
toolchain: stable
profile: minimal # minimal component installation (ie, no documentation)
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.target }} in
aarch64-unknown-linux-musl) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Show Version Information (Rust, cargo, GCC)
shell: bash
run: |
@ -133,6 +149,8 @@ jobs: @@ -133,6 +149,8 @@ jobs:
runs-on: ubuntu-latest
needs: release
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
@ -141,9 +159,16 @@ jobs: @@ -141,9 +159,16 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
build-args: |
REPO=${{ github.repository }}
VER=${{ github.ref_name }}
platforms: |
linux/amd64
linux/arm64
linux/386
linux/arm/v7
push: ${{ needs.release.outputs.rc == 'false' }}
tags: ${{ github.repository }}:latest, ${{ github.repository }}:${{ github.ref_name }}

24
Dockerfile

@ -1,10 +1,18 @@ @@ -1,10 +1,18 @@
FROM rust:1.61 as builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update && apt-get install --no-install-recommends -y musl-tools
WORKDIR /app
COPY . .
RUN cargo build --target x86_64-unknown-linux-musl --release
FROM alpine as builder
ARG REPO VER TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
TARGET="x86_64-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
TARGET="aarch64-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/386" ]; then \
TARGET="i686-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
TARGET="armv7-unknown-linux-musleabihf"; \
fi && \
wget https://github.com/${REPO}/releases/download/${VER}/dufs-${VER}-${TARGET}.tar.gz && \
tar -xf dufs-${VER}-${TARGET}.tar.gz && \
mv dufs /bin/
FROM scratch
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dufs /bin/
ENTRYPOINT ["/bin/dufs"]
COPY --from=builder /bin/dufs /bin/dufs
ENTRYPOINT ["/bin/dufs"]

Loading…
Cancel
Save