From 965e1d0b7a399f8f98a9a1647ec36b5efd275d5b Mon Sep 17 00:00:00 2001 From: Jan Baudisch Date: Sat, 4 May 2024 14:42:51 +0200 Subject: [PATCH] feat: build container via nix in CI --- .github/workflows/Container.yaml | 29 +++++++++++++++++++++++++++++ flake.nix | 9 ++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/Container.yaml diff --git a/.github/workflows/Container.yaml b/.github/workflows/Container.yaml new file mode 100644 index 00000000..d705a4a2 --- /dev/null +++ b/.github/workflows/Container.yaml @@ -0,0 +1,29 @@ +name: Container + +on: + - push + +env: + REGISTRY: ghcr.io + IMAGE_NAME: softvare-group/d4v2 + TAG: ${{ github.ref_name }} + +jobs: + Build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Nix + uses: DeterminateSystems/nix-installer-action@v10 + - name: Cache + uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Build + run: nix build -L .#container + - name: Login + run: nix run nixpkgs#skopeo -- login $REGISTRY --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} + - name: Push + run: nix run nixpkgs#skopeo -- copy docker-archive:result docker://$REGISTRY/$IMAGE_NAME:$TAG + - name: Push latest tag + if: ${{ github.ref_type == 'tag' }} + run: nix run nixpkgs#skopeo -- copy docker://$REGISTRY/$IMAGE_NAME:$TAG docker://$REGISTRY/$IMAGE_NAME:latest diff --git a/flake.nix b/flake.nix index 801333d2..5fd741c3 100644 --- a/flake.nix +++ b/flake.nix @@ -51,7 +51,14 @@ container = pkgs.dockerTools.buildLayeredImage { name = "d4v2"; contents = [ self.packages.${system}.d4 ]; - config.Entrypoint = [ "/bin/d4" ]; + config = { + Entrypoint = [ "/bin/d4" ]; + Labels = { + "org.opencontainers.image.source" = "https://github.com/SoftVarE-Group/d4v2"; + "org.opencontainers.image.description" = "A CNF to d-DNNF compiler"; + "org.opencontainers.image.licenses" = "LGPL-2.1-or-later"; + }; + }; }; mt-kahypar = pkgs.stdenv.mkDerivation {