-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (53 loc) · 2.26 KB
/
Copy pathrelease.yml
File metadata and controls
60 lines (53 loc) · 2.26 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
name: Release
on:
release:
# Runs when you publish a release in GitHub (draft -> published, or a new
# published release). The release already exists, so we just attach binaries.
types: [published]
permissions:
contents: write # needed to upload release assets
jobs:
release:
name: Build & attach binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build and package all targets
env:
TAG: ${{ github.event.release.tag_name }}
run: |
mkdir -p dist build
ver="${TAG#v}" # strip a leading "v" if present
ldflags="-s -w -X github.com/php-debugger/installer/internal/version.Version=${ver}"
# Windows-on-ARM runs x64 under emulation, so one Windows build suffices.
for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
goos="${target%/*}"; arch="${target#*/}"
# Asset OS name: darwin -> macos.
osname="$goos"; [ "$goos" = "darwin" ] && osname="macos"
bin="php-debugger"; [ "$goos" = "windows" ] && bin="php-debugger.exe"
echo "building $osname/$arch"
CGO_ENABLED=0 GOOS="$goos" GOARCH="$arch" \
go build -trimpath -ldflags "$ldflags" -o "build/$bin" .
chmod +x "build/$bin"
# Package into an archive so the executable bit survives download
# (raw GitHub release assets lose Unix permissions).
base="php-debugger-${osname}-${arch}"
if [ "$goos" = "windows" ]; then
(cd build && zip -q "../dist/${base}.zip" "$bin")
else
tar -C build -czf "dist/${base}.tar.gz" "$bin"
fi
rm -f "build/$bin"
done
# Attach the install scripts too, so releases/latest/download/install.sh
# is a stable URL that serves the released version of the script.
cp scripts/install.sh scripts/install.ps1 dist/
ls -la dist
- name: Attach binaries to the release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.release.tag_name }}
run: gh release upload "$TAG" dist/* --clobber