-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.04 KB
/
Copy pathrelease.yml
File metadata and controls
76 lines (65 loc) · 2.04 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.22"
cache: true
cache-dependency-path: go.mod
- run: go test ./...
- name: Build release artifacts
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
build_date="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
mkdir -p dist
platforms=(
"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/arm64"
"windows/amd64"
"windows/arm64"
)
for platform in "${platforms[@]}"; do
IFS=/ read -r goos goarch <<< "${platform}"
artifact_os="${goos}"
if [ "${goos}" = "darwin" ]; then
artifact_os="macos"
fi
name="rdrop_${version}_${artifact_os}_${goarch}"
binary="rdrop"
if [ "${goos}" = "windows" ]; then
binary="rdrop.exe"
fi
mkdir -p "dist/${name}"
CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" \
go build -trimpath \
-ldflags="-s -w -X main.version=${version} -X main.commit=${GITHUB_SHA} -X main.date=${build_date}" \
-o "dist/${name}/${binary}" ./cmd/rdrop
cp README.md LICENSE "dist/${name}/"
if [ "${goos}" = "windows" ]; then
(cd dist && zip -qr "${name}.zip" "${name}")
else
tar -czf "dist/${name}.tar.gz" -C dist "${name}"
fi
rm -rf "dist/${name}"
done
(cd dist && shasum -a 256 * > checksums.txt)
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" dist/* \
--title "raindrop-cli ${GITHUB_REF_NAME}" \
--generate-notes