Skip to content

Commit

Permalink
Update rust.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
CA-MKSingh authored Oct 6, 2024
1 parent bce3c41 commit f76e67a
Showing 1 changed file with 7 additions and 50 deletions.
57 changes: 7 additions & 50 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ env:
IMAGE_NAME: "shieldauth/shield"

jobs:
build:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v3

Expand All @@ -23,60 +20,20 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Determine version from release
shell: bash
run: |
if [[ "$GITHUB_REF" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)(-alpha|-beta)?$ ]]; then
VERSION="${BASH_REMATCH[1]}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "Invalid release tag format. Exiting."
exit 1
fi
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push Docker image
- name: Build and push multi-arch image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/${{ matrix.arch }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.arch }}
${{ env.IMAGE_NAME }}:latest-${{ matrix.arch }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }}
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max

create-manifests:
needs: build
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Create and push manifest
run: |
# Enable experimental features for manifest support
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
# Create and push version manifest
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ github.ref_name }} \
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64 \
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64
# Create and push latest manifest
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:latest \
${{ env.IMAGE_NAME }}:latest-amd64 \
${{ env.IMAGE_NAME }}:latest-arm64
${{ env.IMAGE_NAME }}:${{ github.ref_name }}
${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max

0 comments on commit f76e67a

Please sign in to comment.