Skip to content

Release Docker

Release Docker #172

name: Release Docker
on:
push:
branches:
- main
tags:
- v* # Match version tags like v1.0.0
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/xs
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- uses: actions/checkout@v4
# Step 2: Set up Rust
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
# Step 3: Build the binary in release mode
- name: Build in release mode
run: cargo build --release --verbose
# Step 4: Install scru128-cli from GitHub
- name: Install scru128-cli from GitHub
run: |
cargo install --git https://github.com/cablehead/scru128-cli --branch main
mv ~/.cargo/bin/scru128 target/release/scru128
# Step 5: Determine Docker image tag based on ref type
- name: Determine image tag
id: image_tag
run: |
echo "GITHUB_REF: ${{ github.ref }}"
echo "GITHUB_REF_NAME: ${{ github.ref_name }}"
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "This is a tag push."
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "This is a branch push."
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
fi
# Step 6: Build Docker image
- name: Build Docker image
run: |
docker build -t $IMAGE_NAME:$IMAGE_TAG -f .github/workflows/Dockerfile.release-docker .
# Step 7: Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# Step 8: Push Docker image to GHCR
- name: Push Docker image
run: docker push $IMAGE_NAME:$IMAGE_TAG