Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish SemVer-tagged images on tag pushes to main #569

Merged
merged 1 commit into from
Dec 21, 2023
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
39 changes: 39 additions & 0 deletions .github/workflows/tagged_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Create SemVer-tagged OCI image
on:
push:
tags:
- '*'

permissions: read-all

jobs:
publish-image:
runs-on: ubuntu-22.04
permissions:
packages: write
id-token: write
steps:

- name: Checkout
uses: >- # v4.1.1
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Install Nix
uses: >- # v7
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test image
run: |
nix run .#local-image-test

- name: Upload image
run: |
nix run .#publish-ghcr ${{github.ref_name}}
env:
GHCR_REGISTRY: ghcr.io
GHCR_USERNAME: ${{ github.actor }}
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GHCR_IMAGE_NAME: ${{ github.repository }}
4 changes: 3 additions & 1 deletion tools/publish-ghcr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pkgs.writeShellScriptBin "publish-ghcr" ''
# nothing would still lead to a new hash. Instead we use the
# derivation hash as the tag so that the tag is reused if the image
# didn't change.
IMAGE_TAG=$(nix eval .#image.imageTag --raw)
#
# If a positional argument is passed it overrides the tag value.
IMAGE_TAG=''${1:-$(nix eval .#image.imageTag --raw)}

TAGGED_IMAGE=''${GHCR_REGISTRY}/''${GHCR_IMAGE_NAME,,}:''${IMAGE_TAG}

Expand Down