Skip to content

v0.1.8-alpha

v0.1.8-alpha #108

Workflow file for this run

name: Rust CI/CD
on:
release:
types: [created]
env:
CARGO_TERM_COLOR: always
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
IMAGE_NAME: "shieldauth/shield"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- 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
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/${{ matrix.arch }}
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: Create and push manifest for version tag
run: |
docker manifest create ${{ env.IMAGE_NAME }}:${{ github.ref_name }} \
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64 \
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64
docker manifest push ${{ env.IMAGE_NAME }}:${{ github.ref_name }}
- name: Create and push manifest for latest tag
run: |
docker manifest create ${{ env.IMAGE_NAME }}:latest \
${{ env.IMAGE_NAME }}:latest-amd64 \
${{ env.IMAGE_NAME }}:latest-arm64
docker manifest push ${{ env.IMAGE_NAME }}:latest