Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanCacqueray committed Nov 14, 2024
1 parent 408a47f commit 19b75aa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
create-container-release:
name: create-container-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Push Image
run: nix run ".#publish-container-release"
env:
GH_USERNAME: ${{ github.actor }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
pkgs = import nixpkgs { inherit system; };
python = pkgs.python311.withPackages
(ps: [ ps.openstacksdk ps.prometheus-client ps.pyyaml ]);

info = builtins.fromTOML (builtins.readFile ./pyproject.toml);

container-name = "ghcr.io/tristancacqueray/zuul-capacity";
container = pkgs.dockerTools.streamLayeredImage {
name = container-name;
Expand All @@ -27,8 +30,26 @@
};
};

publish-container-release =
pkgs.writeShellScriptBin "container-release" ''
set -e
export PATH=$PATH:${pkgs.gzip}/bin:${pkgs.skopeo}/bin
IMAGE="docker://${container-name}"
echo "Logging to registry..."
echo $GH_TOKEN | skopeo login --username $GH_USERNAME --password-stdin ghcr.io
echo "Building and publishing the image..."
${container} | gzip --fast | skopeo copy docker-archive:/dev/stdin $IMAGE:${info.project.version}
echo "Tagging latest"
skopeo copy $IMAGE:${info.project.version} $IMAGE:latest
'';

in {
packages.container = container;
apps.publish-container-release =
flake-utils.lib.mkApp { drv = publish-container-release; };
devShell = pkgs.mkShell { buildInputs = with pkgs; [ uv ]; };
});
}

0 comments on commit 19b75aa

Please sign in to comment.