-
Notifications
You must be signed in to change notification settings - Fork 45
141 lines (125 loc) · 4.6 KB
/
Copy pathrelease.yml
File metadata and controls
141 lines (125 loc) · 4.6 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
137
138
139
140
141
name: Release
on:
release:
types: [created]
permissions:
contents: write
jobs:
quality-checks:
name: Quality and Security Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.27'
cache: true
- name: Run Tests
run: |
go test -v -race ./...
./test/late-podman-test.sh
- name: Run Go Vet
run: go vet ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.13.2
- name: Run govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: '1.27'
go-package: ./...
build-and-release:
needs: quality-checks
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: amd64
- os: linux
arch: arm64
- os: darwin
arch: amd64
- os: darwin
arch: arm64
- os: windows
arch: amd64
- os: windows
arch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.27'
- name: Build Binary
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: |
OUTPUT_NAME=late-${{ matrix.os }}-${{ matrix.arch }}
if [ "${{ matrix.os }}" = "windows" ]; then
OUTPUT_NAME="${OUTPUT_NAME}.exe"
fi
go build -ldflags "-X late/internal/common.Version=${{ github.ref_name }} -X late/internal/common.BuildNumber=${{ github.run_number }} -X late/internal/common.Commit=${{ github.sha }} -X 'late/internal/common.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" -o $OUTPUT_NAME ./cmd/late
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
files: late-${{ matrix.os }}-${{ matrix.arch }}*
update-homebrew:
needs: build-and-release
runs-on: ubuntu-latest
steps:
- name: Download release binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.ref_name }}
run: |
for target in darwin-arm64 darwin-amd64 linux-arm64 linux-amd64; do
curl -sL -o "late-${target}" \
"https://github.com/mlhher/late-cli/releases/download/${VERSION}/late-${target}"
done
- name: Compute SHA256 hashes
id: hashes
run: |
echo "darwin_arm64=$(sha256sum late-darwin-arm64 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "darwin_amd64=$(sha256sum late-darwin-amd64 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "linux_arm64=$(sha256sum late-linux-arm64 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "linux_amd64=$(sha256sum late-linux-amd64 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Clone tap and update formula
env:
VERSION: ${{ github.ref_name }}
run: |
git clone https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/mlhher/homebrew-late.git tap
cd tap
CLEAN_VERSION="${VERSION#v}"
# Replace version and sha256 values in-place (matches existing values, not placeholders)
sed -i "s/version \".*\"/version \"${CLEAN_VERSION}\"/" Formula/late.rb
# Each sha256 line is unique by context (order: darwin-arm64, darwin-amd64, linux-arm64, linux-amd64)
python3 -c "
import re, sys
with open('Formula/late.rb') as f:
content = f.read()
hashes = {
'darwin-arm64': '${{ steps.hashes.outputs.darwin_arm64 }}',
'darwin-amd64': '${{ steps.hashes.outputs.darwin_amd64 }}',
'linux-arm64': '${{ steps.hashes.outputs.linux_arm64 }}',
'linux-amd64': '${{ steps.hashes.outputs.linux_amd64 }}',
}
for target, sha in hashes.items():
content = re.sub(
r'(late-' + re.escape(target) + r'\")\s*\n\s*sha256 \"[a-f0-9]+\"',
r'\1\n sha256 \"' + sha + '\"',
content
)
with open('Formula/late.rb', 'w') as f:
f.write(content)
"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/late.rb
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "Update late to ${CLEAN_VERSION}"
git push