Skip to content

Commit

Permalink
tag images semver
Browse files Browse the repository at this point in the history
  • Loading branch information
jashandeep-sohi committed Aug 6, 2024
1 parent 9eb79e1 commit 40a342d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/build-containers.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
name: Build Contianers
on:
push:
branches:
branches:
- master

jobs:
build:
concurrency:
group: container

runs-on: ubuntu-latest
permissions:
id-token: "write"
contents: "read"
packages: write

steps:
- uses: docker/metadata-action@v5
id: meta
with:
tags: |
type=ref,event=branch
type=semver,pattern=v{{major}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix run .#sealContainer.copyTo --impure -- --dest-username ${{ github.actor}} --dest-password '${{ secrets.GITHUB_TOKEN }}' docker://ghcr.io/${{ github.repository }}/seal
- run: nix run .#unsealContainer.copyTo --impure -- --dest-username ${{ github.actor}} --dest-password '${{ secrets.GITHUB_TOKEN }}' docker://ghcr.io/${{ github.repository }}/unseal
- run: |-
echo '{ name = "${{ github.ref_name }}"; url = "https://github.com/${{ github.repository }}"; }' > version.nix
for tag in $(jq -r '.tags[]' <<< "$DOCKER_METADATA_OUTPUT_JSON"); do
nix run .#sealContainer.copyTo --impure -- --dest-username ${{ github.actor}} --dest-password '${{ secrets.GITHUB_TOKEN }}' docker://ghcr.io/${{ github.repository }}/seal:$tag
nix run .#unsealContainer.copyTo --impure -- --dest-username ${{ github.actor}} --dest-password '${{ secrets.GITHUB_TOKEN }}' docker://ghcr.io/${{ github.repository }}/unseal:$tag
done
5 changes: 3 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@

perSystem = { config, self', inputs', pkgs, system, ... }:
let
version = with inputs; "${self.shortRev or self.dirtyShortRev or "unknown"}";
homepage = "https://github.com/jashandeep-sohi/krm-fn-sealedsecrets";
versionFile = import ./version.nix;
version = with inputs; "${versionFile.name or self.shortRev or self.dirtyShortRev or "unknown"}";
homepage = versionFile.url or "https://github.com/jashandeep-sohi/krm-fn-sealedsecrets";
buildGoCmd = { pname, cmd }: inputs'.gomod2nix.legacyPackages.buildGoApplication {
inherit pname version;
src = pkgs.lib.cleanSource ./.;
Expand Down
3 changes: 3 additions & 0 deletions version.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file can be used to inject version info during build time.
# { name = "xxx"; url = "xxx"}
{ }

0 comments on commit 40a342d

Please sign in to comment.