-
Notifications
You must be signed in to change notification settings - Fork 15
207 lines (180 loc) · 8.54 KB
/
Copy pathrelease.yml
File metadata and controls
207 lines (180 loc) · 8.54 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Release
on:
push:
tags:
- 'v*' # Triggers on version tags like v1.0.0, v2.1.3, etc.
env:
GO_VERSION: '1.26.5'
permissions:
contents: write # Needed for creating GitHub releases
packages: write # Needed for pushing images/charts to GHCR
jobs:
release:
name: Create Release
runs-on: [self-hosted, rocky8]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4
- name: Download dependencies
run: go mod download
- name: Clean previous dist directory
run: |
rm -rf ./dist || true
- name: Validate tag format
run: |
if [[ ! "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then
echo "Tag ${{ github.ref_name }} does not match expected format (v1.2.3, v1.2.3-beta, or v1.2.3-rc.2)"
exit 1
fi
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v2.4.1
args: release --clean --config .goreleaser.yaml
env:
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get version and commit info
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
COMMIT_SHORT=$(git rev-parse --short=7 HEAD)
BUILD_TIMESTAMP=$(git show -s --format=%cI HEAD)
BRANCH="release"
SOURCE="https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.ref_name }}.tar.gz"
# Check if version contains hyphen (pre-release)
if [[ "$VERSION" == *"-"* ]]; then
IS_PRERELEASE="true"
echo "This is a pre-release version: $VERSION"
else
IS_PRERELEASE="false"
echo "This is a stable release version: $VERSION"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "commit=$COMMIT_SHORT" >> $GITHUB_OUTPUT
echo "build_timestamp=$BUILD_TIMESTAMP" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "source=$SOURCE" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
- name: Prepare fleet-intelligence-agent GHCR image tags
id: agent_image_ghcr
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.version }}"
OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
IMAGE="ghcr.io/${OWNER_LC}/fleet-intelligence-agent"
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
echo "owner_lc=${OWNER_LC}" >> "$GITHUB_OUTPUT"
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
echo "${IMAGE}:${VERSION}" >> "$GITHUB_OUTPUT"
if [ "${{ steps.version.outputs.is_prerelease }}" = "false" ]; then
echo "${IMAGE}:latest" >> "$GITHUB_OUTPUT"
fi
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR (ghcr.io)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push fleet-intelligence-agent image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ steps.agent_image_ghcr.outputs.tags }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
REVISION=${{ steps.version.outputs.commit }}
BUILD_TIMESTAMP=${{ steps.version.outputs.build_timestamp }}
- name: Package Helm chart
run: |
helm package deployments/helm/fleet-intelligence-agent \
--destination dist \
--version "${{ steps.version.outputs.version }}" \
--app-version "${{ steps.version.outputs.version }}"
- name: Login to GHCR Helm registry
run: |
set -euo pipefail
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io \
--username "${{ github.actor }}" \
--password-stdin
- name: Push Helm chart to GHCR (OCI)
run: |
set -euo pipefail
CHART_VERSION="${{ steps.version.outputs.version }}"
OWNER_LC="${{ steps.agent_image_ghcr.outputs.owner_lc }}"
helm push "dist/fleet-intelligence-agent-${CHART_VERSION}.tgz" "oci://ghcr.io/${OWNER_LC}/charts"
- name: Setup JFrog CLI
if: steps.version.outputs.is_prerelease == 'false'
uses: jfrog/setup-jfrog-cli@v4
with:
version: latest
- name: Configure JFrog CLI
if: steps.version.outputs.is_prerelease == 'false'
run: |
jf config add nvidia \
--url="${{ secrets.ARTIFACTORY_URL }}" \
--user="${{ secrets.ARTIFACTORY_USER }}" \
--access-token="${{ secrets.ARTIFACTORY_TOKEN }}" \
--interactive=false \
--overwrite
jf config use nvidia
- name: Upload x86_64 tarball to Artifactory
if: steps.version.outputs.is_prerelease == 'false'
run: |
jf rt upload \
"dist/fleetint-linux-x86_64-${{ steps.version.outputs.version }}.tar.gz" \
"sw-dgxc-gpuhealth-generic-local/KITMAKER/release/fleetint/linux-x86_64/${{ steps.version.outputs.version }}/" \
--flat=true \
--target-props "component_name=fleetint;branch=${{ steps.version.outputs.branch }};os=linux;arch=x86_64;platform=linux-x86_64;version=${{ steps.version.outputs.version }};changelist=${{ steps.version.outputs.commit }};source=${{ steps.version.outputs.source }};category=toolkit"
- name: Upload sbsa tarball to Artifactory
if: steps.version.outputs.is_prerelease == 'false'
run: |
jf rt upload \
"dist/fleetint-linux-sbsa-${{ steps.version.outputs.version }}.tar.gz" \
"sw-dgxc-gpuhealth-generic-local/KITMAKER/release/fleetint/linux-sbsa/${{ steps.version.outputs.version }}/" \
--flat=true \
--target-props "component_name=fleetint;branch=${{ steps.version.outputs.branch }};os=linux;arch=sbsa;platform=linux-sbsa;version=${{ steps.version.outputs.version }};changelist=${{ steps.version.outputs.commit }};source=${{ steps.version.outputs.source }};category=toolkit"
- name: Summary
run: |
echo "### Release Build Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ steps.version.outputs.commit }}" >> $GITHUB_STEP_SUMMARY
echo "**Pre-release:** ${{ steps.version.outputs.is_prerelease }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**fleet-intelligence-agent image tags:**" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.agent_image_ghcr.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Helm chart (GHCR OCI):**" >> $GITHUB_STEP_SUMMARY
echo "repo: oci://ghcr.io/${{ steps.agent_image_ghcr.outputs.owner_lc }}/charts" >> $GITHUB_STEP_SUMMARY
echo "chart: fleet-intelligence-agent:${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ steps.version.outputs.is_prerelease }}" == "true" ]]; then
echo "GitHub release created (pre-release)" >> $GITHUB_STEP_SUMMARY
echo "Artifactory upload skipped (pre-release versions not uploaded to kitmaker)" >> $GITHUB_STEP_SUMMARY
else
echo "GitHub release created" >> $GITHUB_STEP_SUMMARY
echo "Artifacts uploaded to Artifactory:" >> $GITHUB_STEP_SUMMARY
echo "- \`sw-dgxc-gpuhealth-generic-local/KITMAKER/release/fleetint/linux-x86_64/${{ steps.version.outputs.version }}/\`" >> $GITHUB_STEP_SUMMARY
echo "- \`sw-dgxc-gpuhealth-generic-local/KITMAKER/release/fleetint/linux-sbsa/${{ steps.version.outputs.version }}/\`" >> $GITHUB_STEP_SUMMARY
fi