-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (77 loc) · 2.33 KB
/
Copy pathrelease.yaml
File metadata and controls
85 lines (77 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: Version (without leading v, e.g. 1.2.3)
required: true
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
vars:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- id: v
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
REF="${GITHUB_REF#refs/tags/}"
VERSION="${REF#v}"
fi
if [ -z "$VERSION" ]; then
echo "could not determine version" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
image:
needs: vars
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- uses: sigstore/cosign-installer@v4.1.2
- id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ needs.vars.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.vars.outputs.version }}
type=semver,pattern={{major}},value=${{ needs.vars.outputs.version }}
type=raw,value=latest
type=sha,format=short
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: build
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
VERSION=${{ needs.vars.outputs.version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: mode=max
sbom: true
- env:
DIGEST: ${{ steps.build.outputs.digest }}
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: cosign sign --yes "${IMAGE}@${DIGEST}"