-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (73 loc) · 2.74 KB
/
Copy pathrelease.yml
File metadata and controls
81 lines (73 loc) · 2.74 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
version:
description: Release version, for example v0.1.0
required: true
permissions:
contents: write
jobs:
release-binaries:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- uses: azure/setup-helm@v4
- name: Test
run: go test -p 1 ./...
- name: Build release archives
shell: bash
env:
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}
run: |
set -euo pipefail
mkdir -p dist
BUILDINFO_PACKAGE="github.com/Colvin-Y/kubernetes-ontology/internal/buildinfo"
COMMIT="${GITHUB_SHA:-unknown}"
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
targets=(
"linux amd64 tar.gz"
"linux arm64 tar.gz"
"darwin amd64 tar.gz"
"darwin arm64 tar.gz"
"windows amd64 zip"
)
for target in "${targets[@]}"; do
read -r goos goarch format <<< "${target}"
work="dist/kubernetes-ontology_${VERSION}_${goos}_${goarch}"
mkdir -p "${work}"
ext=""
if [ "${goos}" = "windows" ]; then ext=".exe"; fi
for cmd in kubernetes-ontology kubernetes-ontologyd kubernetes-ontology-viewer; do
CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" go build \
-trimpath \
-ldflags="-s -w -X ${BUILDINFO_PACKAGE}.Version=${VERSION} -X ${BUILDINFO_PACKAGE}.Commit=${COMMIT} -X ${BUILDINFO_PACKAGE}.Date=${BUILD_DATE}" \
-o "${work}/${cmd}${ext}" "./cmd/${cmd}"
done
cp README.md README.zh-CN.md QUICKSTART.md CHANGELOG.md AI_CONTRACT.md LICENSE NOTICE SECURITY.md "${work}/"
mkdir -p "${work}/docs"
cp -R docs/assets "${work}/docs/"
mkdir -p "${work}/local"
cp local/kubernetes-ontology.yaml.example "${work}/local/"
if [ "${format}" = "zip" ]; then
(cd dist && zip -qr "$(basename "${work}").zip" "$(basename "${work}")")
else
tar -C dist -czf "${work}.tar.gz" "$(basename "${work}")"
fi
rm -rf "${work}"
done
helm package charts/kubernetes-ontology --destination dist
(cd dist && sha256sum * > checksums.txt)
- name: Create GitHub release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}
generate_release_notes: true
files: dist/*