Skip to content

Commit 758c5d7

Browse files
authored
Publish SemVer-tagged images on tag pushes to main (TraceMachina#569)
1 parent 1039ea0 commit 758c5d7

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

.github/workflows/tagged_image.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Create SemVer-tagged OCI image
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions: read-all
9+
10+
jobs:
11+
publish-image:
12+
runs-on: ubuntu-22.04
13+
permissions:
14+
packages: write
15+
id-token: write
16+
steps:
17+
18+
- name: Checkout
19+
uses: >- # v4.1.1
20+
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
21+
22+
- name: Install Nix
23+
uses: >- # v7
24+
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Test image
29+
run: |
30+
nix run .#local-image-test
31+
32+
- name: Upload image
33+
run: |
34+
nix run .#publish-ghcr ${{github.ref_name}}
35+
env:
36+
GHCR_REGISTRY: ghcr.io
37+
GHCR_USERNAME: ${{ github.actor }}
38+
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
39+
GHCR_IMAGE_NAME: ${{ github.repository }}

tools/publish-ghcr.nix

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ pkgs.writeShellScriptBin "publish-ghcr" ''
1313
# nothing would still lead to a new hash. Instead we use the
1414
# derivation hash as the tag so that the tag is reused if the image
1515
# didn't change.
16-
IMAGE_TAG=$(nix eval .#image.imageTag --raw)
16+
#
17+
# If a positional argument is passed it overrides the tag value.
18+
IMAGE_TAG=''${1:-$(nix eval .#image.imageTag --raw)}
1719
1820
TAGGED_IMAGE=''${GHCR_REGISTRY}/''${GHCR_IMAGE_NAME,,}:''${IMAGE_TAG}
1921

0 commit comments

Comments
 (0)