Skip to content

Commit 91cae8b

Browse files
Merge pull request #7 from artificialio/cd/2025-09-01-add-oci-output
Add oci output and push to ghcr.io on release tag
2 parents 6379851 + 14a7ea4 commit 91cae8b

3 files changed

Lines changed: 98 additions & 3 deletions

File tree

.github/workflows/push.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Push Docker Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: nixbuild/nix-quick-install-action@v28
18+
with:
19+
nix_conf: experimental-features = nix-command flakes
20+
21+
# Log in to GHCR
22+
- name: Log in to GHCR
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
# Create a docker image
30+
- run: nix run .#packages.x86_64-linux.container.copyToDockerDaemon
31+
- run: docker tag perfly:latest ghcr.io/artificialio/perfly:${{ github.event.release.tag_name }}
32+
33+
# Build and push the image
34+
- name: Build and Push Docker image
35+
uses: docker/build-push-action@v6
36+
with:
37+
context: .
38+
push: true
39+
tags: |
40+
ghcr.io/artificialio/perfly:latest
41+
ghcr.io/artificialio/perfly:${{ github.event.release.tag_name }}

flake.lock

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
flake-parts.url = "github:hercules-ci/flake-parts";
55
haskell-flake.url = "github:srid/haskell-flake";
66
hell.url = "github:chrisdone/hell?ref=551133cecdafed1d6d3f4da7d8a466df2eed8af5";
7-
7+
nix2container.url = "github:nlewo/nix2container";
88
};
9-
outputs = inputs@{ self, nixpkgs, flake-parts, hell, ... }:
9+
10+
outputs = inputs@{ self, nixpkgs, flake-parts, hell, nix2container, ... }:
1011
flake-parts.lib.mkFlake { inherit inputs; } {
1112
systems = nixpkgs.lib.systems.flakeExposed;
1213
imports = [ inputs.haskell-flake.flakeModule ];
@@ -52,6 +53,25 @@
5253

5354
# Hook up tests so `nix flake check` runs them
5455
checks.default = self'.packages.perfly;
56+
57+
packages.container = nix2container.packages.${system}.nix2container.buildImage {
58+
name = "perfly";
59+
tag = "latest";
60+
config = {
61+
Cmd = [ "/perfly" ];
62+
WorkingDir = "/";
63+
};
64+
# Extract ONLY the binary, nothing else
65+
copyToRoot = pkgs.runCommand "perfly-only" {} ''
66+
mkdir -p $out
67+
# Copy just the binary, not the entire package closure
68+
cp ${self'.packages.perfly}/bin/perfly $out/perfly
69+
# Strip debug symbols
70+
${pkgs.binutils}/bin/strip $out/perfly 2>/dev/null || true
71+
# Make executable
72+
chmod +x $out/perfly
73+
'';
74+
};
5575
};
5676
};
5777
}

0 commit comments

Comments
 (0)