Skip to content

Commit 8886435

Browse files
committed
feat: 1 CI jobs to pack chocolatey package, 1 CI job to push it
1 parent 99cf736 commit 8886435

File tree

9 files changed

+66
-43
lines changed

9 files changed

+66
-43
lines changed

.github/workflows/build_release_assets.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ jobs:
240240
# automatically do it on Windows
241241
pdm run bash -c "scripts/build-os-packages/build-os-packages $args"
242242
243+
- name: Build Chocolatey package
244+
if: startsWith(matrix.os, 'windows-')
245+
shell: bash
246+
run: |
247+
windows_zip=$(find packages -type f -name "*.zip" | grep "windows" | head -n 1)
248+
scripts/chocolatey/pack $windows_zip packages
249+
243250
- name: Override base Docker image used for functional tests on Windows
244251
if: matrix.os == 'windows-2022'
245252
# This is required because GitHub Windows runner is not configured to
@@ -261,7 +268,6 @@ jobs:
261268
TEST_GG_VALID_TOKEN: ${{ secrets.TEST_GG_VALID_TOKEN }}
262269
TEST_GG_VALID_TOKEN_IGNORE_SHA: ${{ secrets.TEST_GG_VALID_TOKEN_IGNORE_SHA }}
263270
TEST_UNKNOWN_SECRET: ${{ secrets.TEST_UNKNOWN_SECRET }}
264-
265271
- name: Upload artifacts
266272
uses: actions/upload-artifact@v4
267273
with:
@@ -272,6 +278,7 @@ jobs:
272278
packages/ggshield-*.zip
273279
packages/ggshield-*.rpm
274280
packages/ggshield_*.deb
281+
packages/ggshield.*.nupkg
275282
276283
# Run some basic tests, the goal is to verify the ggshield binary has all the
277284
# libraries it needs to run

.github/workflows/tag.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
packages/ggshield_*.deb \
8383
packages/ggshield-*.rpm \
8484
packages/ggshield-*.zip \
85+
packages/ggshield.*.nupkg \
8586
packages/ggshield-*.gz
8687
8788
update_vscode_extension:
@@ -151,19 +152,22 @@ jobs:
151152
push_to_chocolatey:
152153
needs: build_release_assets
153154
name: Push to Chocolatey
154-
runs-on: chocolatey/choco
155+
runs-on: windows-latest
155156
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
156157
steps:
157158
- name: Checkout
158159
uses: actions/checkout@v4
159160

160-
- name: Download packages
161+
- name: Download nupkg
162+
id: download-nupkg
161163
uses: actions/download-artifact@v4
162164
with:
163-
pattern: os-packages-windows-2022
165+
pattern: ggshield.*.nupkg
164166
path: packages
165-
merge-multiple: true
166167

167168
- name: Push to Chocolatey
168169
run: |
169-
scripts/push-to-chocolatey/push-to-chocolatey
170+
nupkg_path=$(find packages -type f -name "*.nupkg" | head -n 1)
171+
scripts/chocolatey/push $nupkg_path
172+
env:
173+
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}

scripts/push-to-chocolatey/README.md renamed to scripts/chocolatey/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Push to Chocolatey
1+
# Chocolatey
22

33
This folder contains everything necessary to build and publish the chocolatey package.
44

File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/chocolatey/pack

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# parse command line arguments
5+
zip_name=$1
6+
output_dir=$2
7+
8+
# unzip to folder
9+
if ! command -v unzip > /dev/null ; then
10+
apt update
11+
apt install unzip
12+
fi
13+
mkdir win_package
14+
unzip $zip_name -d win_package
15+
16+
version=$(echo "$zip_name" | grep -oP '(?<=ggshield-)[0-9.]+')
17+
18+
# choco-package will contain everything needed to build the nupkg
19+
mkdir choco-package
20+
mkdir choco-package/tools
21+
22+
mv win_package/*/_internal choco-package/tools
23+
mv win_package/*/ggshield.exe choco-package/tools
24+
cp scripts/chocolatey/ggshield.nuspec choco-package
25+
cp scripts/chocolatey/VERIFICATION.txt choco-package/tools
26+
cp LICENSE choco-package/tools/LICENSE.txt
27+
sed -i "s/__VERSION__/$version/" choco-package/ggshield.nuspec
28+
29+
choco pack choco-package/* --version $version --outdir $output_dir
30+
31+
rm -rf win_package choco-package

scripts/chocolatey/push

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
die() {
5+
echo $* >&2
6+
exit 1
7+
}
8+
9+
if [ -z "${CHOCOLATEY_API_KEY:-}" ] ; then
10+
die '$CHOCOLATEY_API_KEY is not set'
11+
fi
12+
13+
# parse command line arguments
14+
choco_nupkg=$1
15+
16+
# push to chocolatey
17+
choco push $choco_nupkg --source https://push.chocolatey.org/ --api-key $CHOCOLATEY_API_KEY

scripts/push-to-chocolatey/push-to-chocolatey

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)