]> OzVa Git service - ozva-cloud/commitdiff
chore(ci): publish to docker
authorsigoden <sigoden@gmail.com>
Fri, 3 Jun 2022 02:36:06 +0000 (10:36 +0800)
committerGitHub <noreply@github.com>
Fri, 3 Jun 2022 02:36:06 +0000 (10:36 +0800)
* ci: publish to docker

* update release.yaml

* update Dockerfile

.dockerignore [new file with mode: 0644]
.github/workflows/release.yaml
Dockerfile [new file with mode: 0644]

diff --git a/.dockerignore b/.dockerignore
new file mode 100644 (file)
index 0000000..7e8981e
--- /dev/null
@@ -0,0 +1,13 @@
+# Directories
+/.git/
+/.github/
+/target/
+/examples/
+/docs/
+/benches/
+/tmp/
+
+# Files
+.gitignore
+*.md
+LICENSE*
\ No newline at end of file
index c23b77bf1fa40403898de9996326e4416633f3d7..f7f75e50e4e5eae95dd78ec485b04255691b3f0e 100644 (file)
@@ -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 (file)
index 0000000..108586f
--- /dev/null
@@ -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