-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (138 loc) · 5.32 KB
/
release.yml
File metadata and controls
168 lines (138 loc) · 5.32 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Install Playwright browsers
run: pwsh src/tests/Ninjadog.Tests.E2E/bin/Release/net10.0/playwright.ps1 install chromium
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
- name: Pack
run: dotnet pack --no-build --configuration Release --output ./artifacts
- name: Verify artifacts
run: |
echo "Packages produced:"
ls -la ./artifacts/*.nupkg
test $(ls ./artifacts/*.nupkg | wc -l) -eq 1
- name: Push to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish self-contained binaries
run: |
set -euo pipefail
VERSION="${GITHUB_REF#refs/tags/v}"
for rid in osx-arm64 osx-x64 linux-x64 linux-arm64; do
echo "Publishing for ${rid}..."
dotnet publish src/tools/Ninjadog.CLI/Ninjadog.CLI.csproj \
--configuration Release \
--runtime "${rid}" \
--self-contained \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:DebugType=none \
-p:DebugSymbols=false \
--output "./dist/${rid}"
tar -czf "./dist/ninjadog-${VERSION}-${rid}.tar.gz" \
-C "./dist/${rid}" ninjadog
done
- name: Compute checksums
run: |
set -euo pipefail
cd dist
sha256sum ninjadog-*.tar.gz > checksums.txt
echo "Checksums:"
cat checksums.txt
- name: Upload checksums
uses: actions/upload-artifact@v4
with:
name: checksums
path: dist/checksums.txt
- name: Generate changelog
id: changelog
run: |
set -euo pipefail
CURRENT_TAG="${GITHUB_REF#refs/tags/}"
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -v "^${CURRENT_TAG}$" | head -n 1)
echo "Current tag: ${CURRENT_TAG}"
echo "Previous tag: ${PREVIOUS_TAG}"
if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${CURRENT_TAG}")
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${PREVIOUS_TAG}..${CURRENT_TAG}")
fi
echo "$CHANGELOG" > changelog.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: changelog.txt
files: |
./artifacts/*.nupkg
./dist/ninjadog-*.tar.gz
./dist/checksums.txt
generate_release_notes: true
update-homebrew:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download checksums
uses: actions/download-artifact@v4
with:
name: checksums
- name: Update Homebrew formula
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
set -euo pipefail
VERSION="${GITHUB_REF#refs/tags/v}"
# Extract SHA256 values from checksums
SHA_OSX_ARM64=$(awk '/ninjadog-.*-osx-arm64\.tar\.gz/{print $1}' checksums.txt)
SHA_OSX_X64=$(awk '/ninjadog-.*-osx-x64\.tar\.gz/{print $1}' checksums.txt)
SHA_LINUX_X64=$(awk '/ninjadog-.*-linux-x64\.tar\.gz/{print $1}' checksums.txt)
SHA_LINUX_ARM64=$(awk '/ninjadog-.*-linux-arm64\.tar\.gz/{print $1}' checksums.txt)
# Validate all checksums were extracted
for var in SHA_OSX_ARM64 SHA_OSX_X64 SHA_LINUX_X64 SHA_LINUX_ARM64; do
if [ -z "${!var}" ]; then
echo "ERROR: Failed to extract checksum for ${var}"
exit 1
fi
done
# Generate formula from template
sed \
-e "s|{{VERSION}}|${VERSION}|g" \
-e "s|{{SHA256_OSX_ARM64}}|${SHA_OSX_ARM64}|g" \
-e "s|{{SHA256_OSX_X64}}|${SHA_OSX_X64}|g" \
-e "s|{{SHA256_LINUX_X64}}|${SHA_LINUX_X64}|g" \
-e "s|{{SHA256_LINUX_ARM64}}|${SHA_LINUX_ARM64}|g" \
homebrew/formula-template.rb > ninjadog.rb
# Push to homebrew-tap repo
git clone https://github.com/Atypical-Consulting/homebrew-tap.git tap-repo
cd tap-repo
git remote set-url origin "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/Atypical-Consulting/homebrew-tap.git"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
mkdir -p Formula
cp ../ninjadog.rb Formula/ninjadog.rb
git add Formula/ninjadog.rb
git commit -m "Update ninjadog to ${VERSION}"
git push