From 2476e182f61d209768635e8eca6e75b4acfbd007 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Thu, 11 Apr 2024 09:16:21 +0200 Subject: Change Docker release system --- .github/workflows/push.yml | 56 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bdedfee..30edefa 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,14 +1,11 @@ -name: build and push +name: container on: push: - branches: [ "main" ] - workflow_dispatch: - -env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - CARGO_TERM_COLOR: always + branches: + - "main" + tags: + - "v*.*.*" jobs: test: @@ -22,29 +19,42 @@ jobs: - run: cargo check --release - run: cargo clippy --release - build: + docker: runs-on: ubuntu-latest - needs: test steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: ghcr.io/fxqnlr/webol + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - id: docker_build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: - push: true + context: . platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - tags: | - ghcr.io/fxqnlr/webol:dev-latest - ghcr.io/fxqnlr/webol:dev-${{ github.run_number }} - ghcr.io/fxqnlr/webol:${{ env.CARGO_PKG_VERSION }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} -- cgit v1.2.3