-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (82 loc) · 2.95 KB
/
Copy pathrelease.yml
File metadata and controls
88 lines (82 loc) · 2.95 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
name: New Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
jobs:
release:
runs-on: macos-latest
env:
VERSION: ${{ github.event.inputs.version }}
TAG: v${{ github.event.inputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Binary Tarball
run: |
swift build -c release --disable-sandbox
mv .build/release/netcaps netcaps
tar -czf netcaps-${{ env.VERSION }}-macos-arm64.tar.gz netcaps
- name: Create Git Tag
run: |
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG=v$VERSION" >> $GITHUB_ENV
if [ -f changelog.md ]; then
CHANGELOG=$(cat changelog.md)
else
CHANGELOG="No release notes provided."
fi
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
git config user.name "netcaps-bot"
git config user.email "bot@users.noreply.github.com"
git tag -a "v$VERSION" -m "Version $VERSION"
git push origin "v$VERSION"
- name: Push Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TAG }}
name: "Version ${{ env.VERSION }}"
body: ${{ env.CHANGELOG }}
files: |
netcaps-${{ env.VERSION }}-macos-arm64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Source Tarball sha256
run: |
SRC_URL="https://github.com/forcequitOS/netcaps/archive/refs/tags/${{ env.TAG }}.tar.gz"
OUT="netcaps-${{ env.VERSION }}-src.tar.gz"
for i in {1..10}; do
if curl -sSLf -o "$OUT" "$SRC_URL"; then
break
fi
echo "Source tarball not yet available (attempt $i); retrying..."
sleep 3
done
if [ ! -s "$OUT" ]; then
echo "Failed to download source tarball from $SRC_URL"
exit 1
fi
SHA256=$(shasum -a 256 "$OUT" | cut -d ' ' -f 1)
echo "SHA256=$SHA256" >> $GITHUB_ENV
- name: Update Homebrew Tap
run: |
git clone https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/forcequitOS/homebrew-brew tap
cd tap
sed -i.bak \
-e "s|url \".*\"|url \"https://github.com/forcequitOS/netcaps/archive/refs/tags/${{ env.TAG }}.tar.gz\"|" \
-e "s|sha256 \".*\"|sha256 \"${{ env.SHA256 }}\"|" \
-e "s|version \".*\"|version \"${{ env.VERSION }}\"|" \
netcaps.rb
git config user.name "netcaps-bot"
git config user.email "bot@users.noreply.github.com"
git add netcaps.rb
git commit -m "netcaps ${{ env.VERSION }}"
git push origin main
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}