diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7e8981e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +# Directories +/.git/ +/.github/ +/target/ +/examples/ +/docs/ +/benches/ +/tmp/ + +# Files +.gitignore +*.md +LICENSE* \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c23b77b..f7f75e5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,8 +6,10 @@ on: - v[0-9]+.[0-9]+.[0-9]+* jobs: - all: - name: All + release: + name: Publish to Github Reelases + outputs: + rc: ${{ steps.check-tag.outputs.rc }} strategy: matrix: @@ -123,4 +125,41 @@ jobs: files: ${{ steps.package.outputs.archive }} prerelease: ${{ steps.check-tag.outputs.rc == 'true' }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + docker: + name: Publish to Docker Hub + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: release + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: ${{ needs.release.outputs.rc == 'false' }} + tags: sigoden/duf:latest, sigoden/duf:${{ github.ref_name }} + + publish-crate: + name: Publish to crates.io + if: ${{ needs.release.outputs.rc == 'false' }} + runs-on: ubuntu-latest + needs: release + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - name: Publish + + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }} + run: cargo publish \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..108586f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +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 +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/duf /bin/ +ENTRYPOINT ["/bin/duf"] \ No newline at end of file