-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild-ironic-hardware-exporter.yaml
More file actions
118 lines (105 loc) · 4 KB
/
build-ironic-hardware-exporter.yaml
File metadata and controls
118 lines (105 loc) · 4 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
name: build-ironic-hardware-exporter-images
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (X.Y.Z, without the v prefix)'
required: true
type: string
push:
tags:
- "ironic-hardware-exporter/v*"
paths:
- "go/ironic-hardware-exporter/**"
jobs:
build-ironic-hardware-exporter:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
id-token: write
outputs:
version: ${{ steps.extract_tag.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: '1.25'
cache: true
cache-dependency-path: 'go/ironic-hardware-exporter/go.sum'
- name: Install syft
uses: anchore/sbom-action/download-syft@57aae528053a48a3f6235f2d9461b05fbcb7366d # v0.23.1
- name: Install Cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Login to ghcr.io
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Validate tag format
if: github.event_name != 'workflow_dispatch'
run: |
if [[ ! "$GITHUB_REF" =~ ^refs/tags/ironic-hardware-exporter/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Invalid tag: $GITHUB_REF — expected refs/tags/ironic-hardware-exporter/vX.Y.Z"
exit 1
fi
- name: Validate version input
if: github.event_name == 'workflow_dispatch'
run: |
if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: ${{ inputs.version }} — expected X.Y.Z"
exit 1
fi
- name: Extract release version
id: extract_tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF_NAME#ironic-hardware-exporter/v}" >> $GITHUB_OUTPUT
fi
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --skip=validate
workdir: go/ironic-hardware-exporter
env:
GIT_REPO: ${{ github.repository }}
RELEASE_VERSION: ${{ steps.extract_tag.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
chart:
runs-on: ubuntu-latest
needs:
- build-ironic-hardware-exporter
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Log in to ghcr.io
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
with:
registry: ghcr.io
username: '${{ github.actor }}'
password: '${{ secrets.GITHUB_TOKEN }}'
- name: Package and push Helm chart
working-directory: go/ironic-hardware-exporter
env:
PKG_VER: '${{ needs.build-ironic-hardware-exporter.outputs.version }}'
run: |
yq -i ".version = \"${PKG_VER}\"" helm/Chart.yaml
yq -i ".appVersion = \"${PKG_VER}\"" helm/Chart.yaml
yq helm/Chart.yaml
helm package -u -d ${{ github.workspace }} helm
helm push ${{ github.workspace }}/ironic-hardware-exporter-${PKG_VER}.tgz \
oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts