Skip to content

v0.1.5-alpha

v0.1.5-alpha #105

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"
CIRCLECI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
arch: [x64, arm64]
steps:
- uses: actions/checkout@v3
- name: Install Rust and update to the latest stable version
run: |
rustup update stable
rustup default stable
- 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: Build the project for ${{ matrix.os }} and ${{ matrix.arch }}
if: runner.os == 'Linux'
run: |
docker run --rm -v "$(pwd)":/app -w /app rust:latest-alpine cargo build --release --verbose
- name: Run tests for ${{ matrix.os }} and ${{ matrix.arch }}
if: runner.os == 'Linux'
run: |
docker run --rm -v "$(pwd)":/app -w /app rust:latest-alpine cargo test --verbose
# Native Rust build for macOS and Windows
- name: Build project (non-Linux)
if: runner.os != 'Linux'
run: cargo build --release --verbose
- name: Run tests (non-Linux)
if: runner.os != 'Linux'
run: cargo test --verbose
- name: Log in to DockerHub
if: runner.os == 'Linux'
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Build Docker image (Linux only)
if: runner.os == 'Linux'
run: |
docker buildx build --platform linux/${{ matrix.arch }} \
-t "${{ env.IMAGE_NAME }}:linux_${{ matrix.arch }}:${{ github.ref_name }}" .
- name: Push Docker image to DockerHub (Linux only)
if: runner.os == 'Linux'
run: |
docker tag "${{ env.IMAGE_NAME }}:linux_${{ matrix.arch }}:${{ github.ref_name }}" \
"${{ env.IMAGE_NAME }}:linux_${{ matrix.arch }}:latest"
docker push "${{ env.IMAGE_NAME }}:linux_${{ matrix.arch }}:${{ github.ref_name }}"
docker push "${{ env.IMAGE_NAME }}:linux_${{ matrix.arch }}:latest"