Skip to content

Heimdall, open the bifrost #45

Heimdall, open the bifrost

Heimdall, open the bifrost #45

Workflow file for this run

name: Ahnlich AI and DB Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
prebuild_preparation:
name: Get Binary Type
runs-on: ubuntu-latest
outputs:
bin_name: ${{ steps.get_binary_type.outputs.BIN_NAME }}
bin_suffix: ${{ steps.get_binary_type.outputs.BIN_SUFFIX }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Get Binary Type"
id: get_binary_type
run: |
cd ${{github.workspace}}
echo ${{ github.event.release.tag_name }}
value=$(echo "${{ github.event.release.tag_name }}" | cut -d'/' -f2)
echo "$value"
echo "BIN_SUFFIX=${value}" >> $GITHUB_OUTPUT
echo "BIN_NAME=ahnlich-${value}" >> $GITHUB_OUTPUT
build_linux_binaries_and_publish:
needs: prebuild_preparation
name: Build Linux Binaries
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Get Cargo toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.81.0
- name: Build Linux Release for ${{ needs.prebuild_preparation.outputs.bin_name }}
working-directory: ./ahnlich
run: |
cargo build --release --bin ${{ needs.prebuild_preparation.outputs.bin_name }}
tar -cvzf linux-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz -C target/release ${{ needs.prebuild_preparation.outputs.bin_name }}
gh release upload ${{github.event.release.tag_name}} linux-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash
build_macos_darwin_binaries_and_publish:
needs: prebuild_preparation
name: Build MacOs Darwin Binaries
runs-on: macos-latest
outputs:
bin_name: ${{ needs.prebuild_preparation.outputs.bin_name }}
bin_suffix: ${{ steps.get_binary_type.outputs.BIN_SUFFIX }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Build Aarch64 Darwin Release for ${{ needs.prebuild_preparation.outputs.bin_name }}
working-directory: ./ahnlich
run: |
cargo build --release --target aarch64-apple-darwin --bin ${{ needs.prebuild_preparation.outputs.bin_name }}
tar -cvzf aarch64-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz -C target/aarch64-apple-darwin/release ${{ needs.prebuild_preparation.outputs.bin_name }}
gh release upload ${{github.event.release.tag_name}} aarch64-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash
build_macos_x86_64_binaries_and_publish:
needs: prebuild_preparation
name: Build MacOs x86_64 Binaries
runs-on: macos-13
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Get Cargo toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.81.0
- name: Build x86_64 Apple Darwin Release for ${{ needs.prebuild_preparation.outputs.bin_name }}
working-directory: ./ahnlich
run: |
cargo build --release --target x86_64-apple-darwin --bin ${{ needs.prebuild_preparation.outputs.bin_name }}
tar -cvzf x86_64-apple-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz -C target/x86_64-apple-darwin/release ${{ needs.prebuild_preparation.outputs.bin_name }}
gh release upload ${{github.event.release.tag_name}} x86_64-apple-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash
push_to_registries:
needs: prebuild_preparation
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
if: ${{needs.prebuild_preparation.outputs.bin_name != 'ahnlich-cli'}}
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Cache Docker images
uses: ScribeMD/[email protected]
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('ahnlich/Cargo.lock') }}
- name: Set Port Based on Bin Name
id: set_port
run: |
if [ "${{ needs.prebuild_preparation.outputs.bin_name }}" == "ahnlich-db" ]; then
echo "DEFAULT_PORT=1369" >> $GITHUB_ENV
echo "DESCRIPTION=Ahnlich DB" >> $GITHUB_ENV
else
echo "DEFAULT_PORT=1370" >> $GITHUB_ENV
echo "DESCRIPTION=Ahnlich AI" >> $GITHUB_ENV
fi
- name: Extract version number from tag
id: extract_version
working-directory: ./ahnlich
run: |
# Extract only the numerical version part from the tag
VERSION=$(make workspace-crate-version CRATE_NAME=${{ needs.prebuild_preparation.outputs.bin_suffix }} | tail -n 1)
echo $VERSION
echo "BIN_VERSION=$VERSION" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_GCR_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ghcr.io/${{ github.repository_owner }}/${{needs.prebuild_preparation.outputs.bin_name}}
tags: |
type=schedule
type=semver,pattern={{version}},value=v${{env.BIN_VERSION}}
labels: |
org.opencontainers.image.description=${{ env.DESCRIPTION }}
- name: Build and push Docker images
id: push
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
with:
context: ./ahnlich
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
AHNLICH_BIN=${{ needs.prebuild_preparation.outputs.bin_name}}
DEFAULT_PORT=${{env.DEFAULT_PORT}}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository_owner }}/${{needs.prebuild_preparation.outputs.bin_name}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true