-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (116 loc) · 4.24 KB
/
release.yml
File metadata and controls
134 lines (116 loc) · 4.24 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
strategy:
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-latest
- goos: darwin
goarch: amd64
runner: macos-latest
- goos: darwin
goarch: arm64
runner: macos-latest
- goos: windows
goarch: amd64
runner: windows-latest
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.26"
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
BINARY="probe-${{ matrix.goos }}-${{ matrix.goarch }}${EXT}"
go build -ldflags "-s -w -X github.com/alphawavesystems/flutter-probe/internal/cli.Version=${VERSION}" -o "${BINARY}" ./cmd/probe/
echo "BINARY=${BINARY}" >> "$GITHUB_ENV"
shell: bash
- uses: actions/upload-artifact@v7
with:
name: probe-${{ matrix.goos }}-${{ matrix.goarch }}
path: ${{ env.BINARY }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: Extract changelog section
id: changelog
run: |
VERSION="${GITHUB_REF_NAME#v}"
BODY=""
if [ -f CHANGELOG.md ]; then
BODY=$(awk "/^## .*${VERSION}/{found=1; next} /^## /{if(found) exit} found{print}" CHANGELOG.md)
fi
if [ -z "$BODY" ]; then
BODY="Release ${GITHUB_REF_NAME}"
fi
{
echo "body<<ENDOFBODY"
echo "$BODY"
echo "ENDOFBODY"
} >> "$GITHUB_OUTPUT"
- uses: softprops/action-gh-release@v3
with:
body: ${{ steps.changelog.outputs.body }}
files: artifacts/*
homebrew:
name: Update Homebrew tap
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: Compute SHA256 checksums
id: sha
run: |
echo "darwin_arm64=$(shasum -a 256 artifacts/probe-darwin-arm64 | awk '{print $1}')" >> "$GITHUB_OUTPUT"
echo "darwin_amd64=$(shasum -a 256 artifacts/probe-darwin-amd64 | awk '{print $1}')" >> "$GITHUB_OUTPUT"
echo "linux_amd64=$(shasum -a 256 artifacts/probe-linux-amd64 | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Update formula in homebrew-tap
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
SHA_ARM64="${{ steps.sha.outputs.darwin_arm64 }}"
SHA_AMD64="${{ steps.sha.outputs.darwin_amd64 }}"
SHA_LINUX="${{ steps.sha.outputs.linux_amd64 }}"
git clone "https://x-access-token:${GH_TOKEN}@github.com/AlphaWaveSystems/homebrew-tap.git"
cd homebrew-tap
git config user.name "Patrick Bertsch"
git config user.email "patrick@alphawavesystems.com"
# Update version
sed -i "s/version \"[0-9.]*\"/version \"${VERSION}\"/" Formula/probe.rb
# Update SHA256s — find asset URL line, update the sha256 on the next line
awk -v arm64="$SHA_ARM64" -v amd64="$SHA_AMD64" -v linux="$SHA_LINUX" '
/probe-darwin-arm64/ { print; getline; gsub(/sha256 "[a-f0-9]+"/, "sha256 \"" arm64 "\""); print; next }
/probe-darwin-amd64/ { print; getline; gsub(/sha256 "[a-f0-9]+"/, "sha256 \"" amd64 "\""); print; next }
/probe-linux-amd64/ { print; getline; gsub(/sha256 "[a-f0-9]+"/, "sha256 \"" linux "\""); print; next }
{ print }
' Formula/probe.rb > Formula/probe.rb.tmp && mv Formula/probe.rb.tmp Formula/probe.rb
git add Formula/probe.rb
git commit -m "chore: update probe to v${VERSION}"
git push