Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

watch_file flake.nix
watch_file flake.lock
if ! use flake . --no-pure-eval
then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

160 changes: 160 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: CI/CD

on:
push:
branches: [ main ]
tags: [ '*' ]
pull_request:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
check:
name: Nix CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix flake check -L
- run: nix build -L

build:
name: Build Binary
needs: check
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build -L
- run: mkdir -p target/release && cp result/bin/testaustime target/release/testaustime-rs
- uses: actions/upload-artifact@v4
with:
name: build
path: target/release/testaustime-rs

build-image:
name: Build Docker image
needs: check
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
strategy:
matrix:
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v24
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Set up Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2

- name: Build Docker image with Nix
run: |
nix build -L .#docker
IMAGE_PATH=$(readlink -f result)
echo "IMAGE_PATH=$IMAGE_PATH" >> $GITHUB_ENV

- name: Load Docker image
run: |
docker load < ${{ env.IMAGE_PATH }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine architecture
id: arch
run: |
if [ "${{ matrix.runner }}" = "ubuntu-24.04" ]; then
echo "arch=amd64" >> $GITHUB_OUTPUT
echo "platform=linux/amd64" >> $GITHUB_OUTPUT
else
echo "arch=arm64" >> $GITHUB_OUTPUT
echo "platform=linux/arm64" >> $GITHUB_OUTPUT
fi

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{branch}}-${{ steps.arch.outputs.arch }}
type=raw,value=latest-${{ steps.arch.outputs.arch }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value={{tag}}-${{ steps.arch.outputs.arch }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
flavor: |
latest=false

- name: Get image name from Nix build
id: image
run: |
IMAGE_NAME=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
echo "name=$IMAGE_NAME" >> $GITHUB_OUTPUT

- name: Tag and push Docker image
run: |
for tag in ${{ steps.meta.outputs.tags }};
do
docker tag ${{ steps.image.outputs.name }} $tag
docker push $tag
done

create-manifest:
name: Create multi-arch manifest
needs: build-image
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for manifest
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{branch}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=match,pattern=\d+,group=0,enable=${{ startsWith(github.ref, 'refs/tags/') }}
flavor: |
latest=false

- name: Create and push manifest
run: |
TAGS="${{ steps.meta.outputs.tags }}"
for tag in $TAGS;
do
docker manifest create $tag \
${tag}-amd64 \
${tag}-arm64
docker manifest push $tag
done
61 changes: 0 additions & 61 deletions .github/workflows/docker.yml

This file was deleted.

88 changes: 0 additions & 88 deletions .github/workflows/rust.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ target
*/target
.env
settings.toml
result
.direnv
.devenv
Loading
Loading