add ci and flake support for using ref name to docker image tag

also runs ci on dev branch

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-16 21:55:51 -04:00 committed by June
parent 641399e900
commit 5015fc7a2c
2 changed files with 16 additions and 15 deletions

View file

@ -5,6 +5,7 @@ on:
push: push:
branches: branches:
- main - main
- dev
# Allows you to run this workflow manually from the Actions tab # Allows you to run this workflow manually from the Actions tab
workflow_dispatch: workflow_dispatch:
@ -197,7 +198,7 @@ jobs:
- name: Build oci-image-x86_64-unknown-linux-gnu - name: Build oci-image-x86_64-unknown-linux-gnu
run: | run: |
./bin/nix-build-and-cache .#oci-image ./bin/nix-build-and-cache .#oci-image ${{ github.ref_name }}
cp -v -f result oci-image-amd64.tar.gz cp -v -f result oci-image-amd64.tar.gz
- name: Upload artifact oci-image-x86_64-unknown-linux-gnu - name: Upload artifact oci-image-x86_64-unknown-linux-gnu
@ -211,7 +212,7 @@ jobs:
- name: Build oci-image-x86_64-unknown-linux-gnu-jemalloc - name: Build oci-image-x86_64-unknown-linux-gnu-jemalloc
run: | run: |
./bin/nix-build-and-cache .#oci-image-jemalloc ./bin/nix-build-and-cache .#oci-image-jemalloc ${{ github.ref_name }}
cp -v -f result oci-image-amd64.tar.gz cp -v -f result oci-image-amd64.tar.gz
- name: Upload artifact oci-image-x86_64-unknown-linux-gnu-jemalloc - name: Upload artifact oci-image-x86_64-unknown-linux-gnu-jemalloc
@ -225,7 +226,7 @@ jobs:
- name: Build oci-image-x86_64-unknown-linux-gnu-hmalloc - name: Build oci-image-x86_64-unknown-linux-gnu-hmalloc
run: | run: |
./bin/nix-build-and-cache .#oci-image-hmalloc ./bin/nix-build-and-cache .#oci-image-hmalloc ${{ github.ref_name }}
cp -v -f result oci-image-amd64.tar.gz cp -v -f result oci-image-amd64.tar.gz
- name: Upload artifact oci-image-x86_64-unknown-linux-gnu-hmalloc - name: Upload artifact oci-image-x86_64-unknown-linux-gnu-hmalloc
@ -240,7 +241,7 @@ jobs:
- name: Build oci-image-aarch64-unknown-linux-musl - name: Build oci-image-aarch64-unknown-linux-musl
run: | run: |
./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl ./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl ${{ github.ref_name }}
cp -v -f result oci-image-arm64v8.tar.gz cp -v -f result oci-image-arm64v8.tar.gz
- name: Upload artifact oci-image-aarch64-unknown-linux-musl - name: Upload artifact oci-image-aarch64-unknown-linux-musl
@ -254,7 +255,7 @@ jobs:
- name: Build oci-image-aarch64-unknown-linux-musl-jemalloc - name: Build oci-image-aarch64-unknown-linux-musl-jemalloc
run: | run: |
./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl-jemalloc ./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl-jemalloc ${{ github.ref_name }}
cp -v -f result oci-image-arm64v8.tar.gz cp -v -f result oci-image-arm64v8.tar.gz
- name: Upload artifact oci-image-aarch64-unknown-linux-musl-jemalloc - name: Upload artifact oci-image-aarch64-unknown-linux-musl-jemalloc
@ -268,7 +269,7 @@ jobs:
- name: Build oci-image-aarch64-unknown-linux-musl-hmalloc - name: Build oci-image-aarch64-unknown-linux-musl-hmalloc
run: | run: |
./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl-hmalloc ./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl-hmalloc ${{ github.ref_name }}
cp -v -f result oci-image-arm64v8.tar.gz cp -v -f result oci-image-arm64v8.tar.gz
- name: Upload artifact oci-image-aarch64-unknown-linux-musl-hmalloc - name: Upload artifact oci-image-aarch64-unknown-linux-musl-hmalloc
@ -347,8 +348,8 @@ jobs:
# Tag and push the git ref # Tag and push the git ref
docker manifest create $IMAGE_NAME:$GITHUB_REF_NAME --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8 docker manifest create $IMAGE_NAME:$GITHUB_REF_NAME --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8
docker manifest push $IMAGE_NAME:$GITHUB_REF_NAME docker manifest push $IMAGE_NAME:$GITHUB_REF_NAME
# Tag git tags as 'latest' # Tag "main" as latest (stable branch)
if [[ -n "$GITHUB_REF_NAME" ]]; then if [[ "$GITHUB_REF_NAME" = "main" ]]; then
docker manifest create $IMAGE_NAME:latest --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8 docker manifest create $IMAGE_NAME:latest --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8
docker manifest push $IMAGE_NAME:latest docker manifest push $IMAGE_NAME:latest
fi fi
@ -376,8 +377,8 @@ jobs:
# Tag and push the git ref # Tag and push the git ref
docker manifest create $IMAGE_NAME:$GITHUB_REF_NAME --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8 docker manifest create $IMAGE_NAME:$GITHUB_REF_NAME --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8
docker manifest push $IMAGE_NAME:$GITHUB_REF_NAME docker manifest push $IMAGE_NAME:$GITHUB_REF_NAME
# Tag git tags as 'latest' # Tag "main" as latest (stable branch)
if [[ -n "$GITHUB_REF_NAME" ]]; then if [[ -n "$GITHUB_REF_NAME" = "main" ]]; then
docker manifest create $IMAGE_NAME:latest --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8 docker manifest create $IMAGE_NAME:latest --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_AMD64 --amend $IMAGE_NAME:$GITHUB_SHA-$IMAGE_SUFFIX_ARM64V8
docker manifest push $IMAGE_NAME:latest docker manifest push $IMAGE_NAME:latest
fi fi

View file

@ -193,10 +193,10 @@
meta.mainProgram = cargoToml.package.name; meta.mainProgram = cargoToml.package.name;
}; };
mkOciImage = pkgs: package: allocator: mkOciImage = pkgs: package: allocator: tag:
pkgs.dockerTools.buildImage { pkgs.dockerTools.buildImage {
name = package.pname; name = package.pname;
tag = "main"; tag = "${tag}";
copyToRoot = [ copyToRoot = [
pkgs.dockerTools.caCertificates pkgs.dockerTools.caCertificates
]; ];
@ -218,9 +218,9 @@
default = mkPackage pkgsHost null; default = mkPackage pkgsHost null;
jemalloc = mkPackage pkgsHost "jemalloc"; jemalloc = mkPackage pkgsHost "jemalloc";
hmalloc = mkPackage pkgsHost "hmalloc"; hmalloc = mkPackage pkgsHost "hmalloc";
oci-image = mkOciImage pkgsHost self.packages.${system}.default null; oci-image = mkOciImage pkgsHost self.packages.${system}.default null null;
oci-image-jemalloc = mkOciImage pkgsHost self.packages.${system}.default "jemalloc"; oci-image-jemalloc = mkOciImage pkgsHost self.packages.${system}.default "jemalloc" null;
oci-image-hmalloc = mkOciImage pkgsHost self.packages.${system}.default "hmalloc"; oci-image-hmalloc = mkOciImage pkgsHost self.packages.${system}.default "hmalloc" null;
book = book =
let let