-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (117 loc) · 4.14 KB
/
Copy pathbuild-release.yml
File metadata and controls
139 lines (117 loc) · 4.14 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
name: build-release
on:
push:
branches:
- main
- master
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
package-macos:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build
- name: Build
run: cmake --build build -j4
- name: Test
run: ctest --test-dir build --output-on-failure
- name: Install Staging
run: cmake --install build --prefix "$GITHUB_WORKSPACE/dist/install"
- name: Package
run: cpack --config build/CPackConfig.cmake
- name: Create Source Archive
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION="${GITHUB_REF_NAME#v}"
git archive --format=tar.gz --prefix="mtop-${VERSION}/" "$GITHUB_REF_NAME" > "mtop-${VERSION}-source.tar.gz"
- name: Collect Artifacts
run: |
mkdir -p dist/artifacts
shopt -s nullglob
for file in mtop-*.tar.gz; do
mv "$file" dist/artifacts/
done
find dist -maxdepth 3 -type f | sort
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: mtop-macos-package
path: |
dist/artifacts/*
dist/install/**
- name: Publish GitHub Release Assets
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: dist/artifacts/*
sync-homebrew-tap:
if: startsWith(github.ref, 'refs/tags/v')
needs: package-macos
runs-on: macos-14
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve Version
id: version
run: echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Resolve SHA256
id: sha
run: |
VERSION="${{ steps.version.outputs.value }}"
curl -L -o "/tmp/mtop-${VERSION}-source.tar.gz" "https://github.com/lxrzlyr/mtop/releases/download/v${VERSION}/mtop-${VERSION}-source.tar.gz"
echo "value=$(shasum -a 256 /tmp/mtop-${VERSION}-source.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Start SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.HOMEBREW_TAP_SSH_KEY }}
- name: Trust GitHub Host Key
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Clone Homebrew Tap
run: git clone git@github.com:lxrzlyr/homebrew-mtop.git /tmp/homebrew-mtop
- name: Generate Formula
run: |
./scripts/generate_homebrew_formula.sh \
"${{ steps.version.outputs.value }}" \
"${{ steps.sha.outputs.value }}" \
/tmp/homebrew-mtop/Formula/mtop.rb
- name: Commit And Push
run: |
cd /tmp/homebrew-mtop
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/mtop.rb
if git diff --cached --quiet; then
echo "No tap changes to commit"
exit 0
fi
git commit -m "Update mtop formula to v${{ steps.version.outputs.value }}"
git push origin main
- name: Verify Tap Update
run: |
rm -rf /tmp/homebrew-mtop-verify
git clone git@github.com:lxrzlyr/homebrew-mtop.git /tmp/homebrew-mtop-verify
EXPECTED_VERSION="${{ steps.version.outputs.value }}"
ACTUAL_VERSION=$(python3 - <<'PY'
from pathlib import Path
import re
text = Path('/tmp/homebrew-mtop-verify/Formula/mtop.rb').read_text()
match = re.search(r'/releases/download/v([^/]+)/mtop-([^/]+)-source\.tar\.gz', text)
print(match.group(1) if match else '')
PY
)
if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]]; then
echo "Tap verification failed: expected v${EXPECTED_VERSION}, got v${ACTUAL_VERSION}" >&2
exit 1
fi