-
-
Notifications
You must be signed in to change notification settings - Fork 8
223 lines (181 loc) · 6.33 KB
/
release-binaries.yml
File metadata and controls
223 lines (181 loc) · 6.33 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Build and Publish Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
NODE_VERSION: 20
PYTHON_VERSION: "3.12"
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: darwin-arm64
runner: macos-latest
- target: linux-x64
runner: ubuntu-latest
- target: linux-arm64
runner: ubuntu-24.04-arm
- target: win-x64
runner: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e .
python -m pip install pyinstaller
- name: Build PyInstaller binary
run: python scripts/build_pyinstaller.py
# Generate checksum
- name: Generate checksum
shell: bash
run: |
cd node_version/dist/native/${{ matrix.target }}
for f in explainthisrepo*; do
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$f" > "$f.sha256"
else
shasum -a 256 "$f" > "$f.sha256"
fi
done
- name: Upload native binary + checksum
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: node_version/dist/native/${{ matrix.target }}
release:
name: Publish npm and GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download native binaries
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Rehydrate native folder
shell: bash
run: |
mkdir -p node_version/dist/native dotnet_version/native release
for artifact in artifacts/*; do
[ -d "$artifact" ] || continue
target="$(basename "$artifact")"
mkdir -p "node_version/dist/native/$target"
mkdir -p "dotnet_version/native/$target"
cp "$artifact"/explainthisrepo* "node_version/dist/native/$target/"
cp "$artifact"/explainthisrepo* "dotnet_version/native/$target/"
cp "$artifact"/explainthisrepo* release/
done
# HARD STOP if tampered
- name: Verify checksums
shell: bash
run: |
for checksum in $(find node_version/dist/native -name '*.sha256' | sort); do
dir="$(dirname "$checksum")"
(
cd "$dir"
sha256sum -c "$(basename "$checksum")"
)
done
- name: Verify native binaries exist
shell: bash
run: |
find node_version/dist/native -type f | sort
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org
cache: npm
cache-dependency-path: node_version/package-lock.json
- name: Install Node deps
working-directory: node_version
run: npm ci
- name: Sync version with tag
working-directory: node_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
CURRENT=$(node -p "require('./package.json').version")
if [ "$VERSION" != "$CURRENT" ]; then
npm version $VERSION --no-git-tag-version
else
echo "Version already matches tag, skipping"
fi
- name: Check if npm version exists
working-directory: node_version
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
if npm view "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then
echo "Version already exists on npm"
exit 1
fi
- name: Sync package metadata
working-directory: node_version
run: npm run sync-meta
- name: Build package tarball
working-directory: node_version
run: npm pack
- name: Verify package contains native binaries
working-directory: node_version
run: |
TAR=$(ls *.tgz)
tar -tf "$TAR" | grep "dist/native" || (echo "Missing native binaries in package" && exit 1)
- name: Package check
working-directory: node_version
run: npm pack --dry-run
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Sync .NET version with tag
working-directory: dotnet_version
shell: bash
run: |
VERSION=${GITHUB_REF#refs/tags/v}
CURRENT=$(grep -oPm1 "(?<=<Version>)[^<]+" ExplainThisRepo.csproj)
if [ "$VERSION" != "$CURRENT" ]; then
sed -i "s|<Version>.*</Version>|<Version>$VERSION</Version>|" ExplainThisRepo.csproj
else
echo "Version already matches tag, skipping"
fi
- name: Build and Pack .NET Global Tool
working-directory: dotnet_version
run: dotnet pack -c Release
- name: Check if NuGet version exists
working-directory: dotnet_version
shell: bash
run: |
PACKAGE_ID=$(grep -oPm1 "(?<=<ToolCommandName>)[^<]+" ExplainThisRepo.csproj)
VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" ExplainThisRepo.csproj)
if curl -fsSL "https://api.nuget.org/v3-flatcontainer/${PACKAGE_ID,,}/index.json" | grep "\"$VERSION\"" >/dev/null; then
echo "Version already exists on NuGet"
exit 1
fi
- name: Publish to NuGet
working-directory: dotnet_version
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
if: ${{ env.NUGET_API_KEY != '' }}
run: dotnet nuget push nupkg/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true