From 999598ea01c2d9e292f99ec3fd7c3e7502eec3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88ran=20Malek?= Date: Thu, 26 Aug 2021 11:17:43 +0200 Subject: [PATCH] Workflow to create docker image for duck. --- .github/workflows/duck.yml | 56 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 6 ++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/duck.yml create mode 100644 Dockerfile diff --git a/.github/workflows/duck.yml b/.github/workflows/duck.yml new file mode 100644 index 0000000000..e02d76630f --- /dev/null +++ b/.github/workflows/duck.yml @@ -0,0 +1,56 @@ +name: Create duck image +on: + push: + tags: ['*'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + name: build + runs-on: ubuntu-20.04 + steps: + - name: Sanitize Version + run: | + export VERSION=${GITHUB_REF#refs/tags/release-} + export VERSION=${VERSION//-/.} + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{env.VERSION}} + type=semver,pattern={{major}}.{{minor}},value=${{env.VERSION}} + type=semver,pattern={{major}},value=${{env.VERSION}} + - name: Set up JDK 15 + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 15 + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: | + export COUNT=$(git rev-list --count $GITHUB_SHA) + mvn -B verify --projects cli/linux --also-make -DskipTests + dpkg-deb -R cli/linux/target/release/duck_${{env.VERSION}}.$COUNT-1_amd64.deb . + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v2 + env: + DOCKER_BUILDKIT: 1 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..a1aa5f9671 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM ubuntu:focal +ENTRYPOINT ["/usr/bin/duck"] +CMD ["--version"] + +COPY opt/duck /opt/duck +RUN ln -s /opt/duck/bin/duck /usr/bin/duck