Skip to content

1.2.1

1.2.1 #45

Workflow file for this run

name: Deploy to DockerHub
on:
workflow_dispatch:
inputs:
version:
description: "Version"
required: true
default: "1.0.0"
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { platform: linux-amd64, dist: "debian", target: x86_64-unknown-linux-gnu }
- { platform: linux-arm64, dist: "debian", target: aarch64-unknown-linux-gnu }
- { platform: linux-amd64, dist: "alpine", target: x86_64-unknown-linux-musl }
- { platform: linux-arm64, dist: "alpine", target: aarch64-unknown-linux-musl }
environment: PROD
env:
CARGO_SERVER_SSL_CA: ${{ secrets.SERVER_SSL_CA }}
CARGO_SERVER_SSL_CERT: ${{ secrets.SERVER_SSL_CERT }}
CARGO_SERVER_SSL_KEY: ${{ secrets.SERVER_SSL_KEY }}
FILENAME: ${{ matrix.config.dist}}-${{ matrix.config.platform }}
steps:
# Preparation Steps
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain and components
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.config.target }}"
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Create empty .env file
run: touch .env
- name: Install cross (Linux ARM64 and musl only)
if: matrix.config.target != 'x86_64-unknown-linux-gnu'
run: cargo install cross
- name: Build Binary (Cross)
if: matrix.config.target != 'x86_64-unknown-linux-gnu'
run: cross build --locked --release --target ${{ matrix.config.target }}
- name: Build Binary (Cargo)
if: matrix.config.target == 'x86_64-unknown-linux-gnu'
run: cargo build --locked --release --target ${{ matrix.config.target }}
# - name: Run Tests
# run: cross test --verbose --target ${{ matrix.config.target }}
- name: Move and rename binary
run: |
mkdir -p build
cp target/${{ matrix.config.target }}/release/tagoio-relay build/${{ env.FILENAME }}
# Upload artifacts if this is not a release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.FILENAME }}
retention-days: 1
path: build/${{ env.FILENAME }}
push-to-dockerhub:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- { dist: "debian", architecture: "linux/amd64,linux/arm64/v8" }
- { dist: "alpine", architecture: "linux/amd64,linux/arm64/v8" }
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: build
pattern: ${{ matrix.dist }}-*
merge-multiple: true
- name: List files
run: ls -la build
# - name: Ensure tagoio-relay exists
# run: |
# if [ ! -f build/tagoio-relay ]; then
# echo "tagoio-relay not found in build folder"
# exit 1
# fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# linux/arm64/v8,linux/amd64
- name: Build and deploy images
run: bash dockerhub.sh ${{ matrix.dist }} ${{ matrix.architecture }} ${{ github.event.inputs.version || github.event.release.tag_name }}