-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (121 loc) · 4.25 KB
/
release.yaml
File metadata and controls
136 lines (121 loc) · 4.25 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
# Copyright 2026 The Fluid Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Publishes tarball artifacts to a GitHub Release when a semver tag is pushed,
# or when this workflow is run manually against an existing tag.
# Builds use plain `go build` — no container DAG / Dagger.
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Existing git tag to build and publish (e.g. v1.0.0)"
required: true
type: string
concurrency:
group: release-${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Vet
run: go vet ./...
- name: Test (race)
run: go test ./... -count=1 -race -timeout=5m
release:
needs: test
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Resolve release tag
id: meta
shell: bash
run: |
set -euo pipefail
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
TAG="${TAG#refs/tags/}"
if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error ::Tag must look like vMAJOR.MINOR.PATCH (got: ${TAG})"
exit 1
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "Releasing ${TAG}"
- name: Build release archives
env:
TAG: ${{ steps.meta.outputs.tag }}
shell: bash
run: |
set -euo pipefail
COMMIT="$(git rev-parse --short HEAD)"
DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
# Match Makefile versioning; use reproducible-ish builds on the runner.
LDFLAGS="-s -w \
-X github.com/fluid-cloudnative/fluid-cli/cmd/fluid/internal/version.Version=${TAG} \
-X github.com/fluid-cloudnative/fluid-cli/cmd/fluid/internal/version.GitCommit=${COMMIT} \
-X github.com/fluid-cloudnative/fluid-cli/cmd/fluid/internal/version.BuildDate=${DATE}"
mkdir -p artifacts tmp
for os in linux darwin; do
for arch in amd64 arm64; do
dir="tmp/fluid_${TAG}_${os}_${arch}"
mkdir -p "$dir"
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
go build -trimpath -buildid= -ldflags="${LDFLAGS}" -o "$dir/fluid" ./cmd/fluid
tar -czf "artifacts/fluid_${TAG}_${os}_${arch}.tar.gz" -C "$dir" fluid
done
done
rm -rf tmp
( cd artifacts && sha256sum fluid_*.tar.gz > checksums.txt )
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: Fluid CLI ${{ steps.meta.outputs.tag }}
files: |
artifacts/*.tar.gz
artifacts/checksums.txt
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}