Repository navigation
92 lines (75 loc) · 2.74 KB
/
Copy pathgo-release.yml
File metadata and controls
92 lines (75 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
82
83
84
85
86
87
88
89
90
91
92
name: Go Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build all platforms
env:
VERSION: ${{ github.ref_name }}
COMMIT: ${{ github.sha }}
run: |
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"
platforms="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64"
for platform in $platforms; do
os="${platform%/*}"
arch="${platform#*/}"
ext=""
if [ "$os" = "windows" ]; then ext=".exe"; fi
output="dist/tinycode-${os}-${arch}${ext}"
echo "Building ${output}..."
GOOS=$os GOARCH=$arch go build -ldflags "$LDFLAGS" -o "$output" ./cmd/tinycode/
done
- name: Create release archives
run: |
mkdir -p dist/release
platforms="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64"
for platform in $platforms; do
os="${platform%/*}"
arch="${platform#*/}"
ext=""
if [ "$os" = "windows" ]; then ext=".exe"; fi
binary="dist/tinycode-${os}-${arch}${ext}"
archiveName="tinycode-${os}-${arch}"
mkdir -p "dist/release/${archiveName}"
cp "$binary" "dist/release/${archiveName}/tinycode${ext}"
if [ "$os" = "windows" ]; then
(cd dist/release && zip -q "${archiveName}.zip" "${archiveName}/tinycode${ext}")
else
tar -czf "dist/release/${archiveName}.tar.gz" -C dist/release "${archiveName}"
fi
rm -rf "dist/release/${archiveName}"
done
- name: Package plugin release bundles
run: make package-plugins
- name: Generate checksums
run: |
cd dist/release
sha256sum * > checksums-sha256.txt
- name: Print checksums
run: cat dist/release/checksums-sha256.txt
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view ${{ github.ref_name }} &>/dev/null; then
echo "Release ${{ github.ref_name }} already exists, uploading assets..."
gh release upload ${{ github.ref_name }} dist/release/* --clobber
else
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--generate-notes \
dist/release/*
fi