Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ name: publish
on:
workflow_dispatch:
push:
branches:
- main
tags:
- "v*"
permissions:
Expand All @@ -25,19 +23,15 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push versioned tag
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: nix run .#push -- "v$(cat version.txt)"
Comment thread
charludo marked this conversation as resolved.
- name: Push latest tag (main only)
if: github.ref == 'refs/heads/main'
run: nix run .#push -- latest
- name: Render manifest and publish release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ref=$(nix run .#push -- "${{ github.ref_name }}")
nix run .#push -- latest > /dev/null
out="$RUNNER_TEMP/collateral-proxy.yml"
nix run .#render-k8s-resources > "$out"
nix run .#render-k8s-resources -- "$ref" > "$out"
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The proxy preserves the path and query and rewrites only the host, so clients on
- Build the binary: `nix build .#collateral-proxy`.
- Build the container image: `nix build .#container`.
- Push the image: `nix run .#push -- [tag]` (defaults to the `:dev`).
- Push the image and render the pinned deployment manifest: `nix run .#render-k8s-resources -- [tag]`.
- Render the deployment manifest pinned to a pushed image: `nix run .#render-k8s-resources -- "$(nix run .#push -- dev)"`.
- Format: `nix fmt`.
- Lint: `nix run .#lint`.
- Vuln scan: `nix run .#govulncheck`.
Expand All @@ -125,6 +125,4 @@ The proxy preserves the path and query and rewrites only the host, so clients on

3. Open a PR and merge to `main`.

4. CI running on main publishes `ghcr.io/edgelesssys/collateral-proxy:v0.X.0` and moves `:latest`.

5. Push the `v0.X.0` tag. CI then publishes a GitHub Release and attaches `collateral-proxy.yaml`, the deployment manifest pinned to `v0.X.0@sha256:<digest>`.
4. Push the `v0.X.0` tag. CI then publishes `ghcr.io/edgelesssys/collateral-proxy:v0.X.0`, moves `:latest`, and creates a GitHub Release with `collateral-proxy.yaml` attached.
10 changes: 6 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,25 @@
'';
};

# Push the image and render the deployment manifest to stdout.
# Render the deployment manifest to stdout.
render-k8s-resources = pkgs.writeShellApplication {
name = "render-k8s-resources";
runtimeInputs = [
push
pkgs.gnugrep
pkgs.gnused
];
text = ''
trap 'echo "render-k8s-resources: failed (exit $?) at line $LINENO: $BASH_COMMAND" >&2' ERR
tag="''${1:-v${version}}"
if [[ $# -ne 1 ]]; then
echo "usage: render-k8s-resources ${image}:<tag>@sha256:<digest>" >&2
exit 1
fi
ref=$1
template=${./collateral-proxy.yml}
if ! grep -q '%%pin%%' "$template"; then
echo "render-k8s-resources: template $template is missing the %%pin%% placeholder" >&2
exit 1
fi
ref=$(push-collateral-proxy "$tag")
sed "s|%%pin%%|$ref|" "$template"
'';
};
Expand Down
Loading