Skip to content

Commit f956412

Browse files
committed
Update test-apt-repo.yml
1 parent 474454d commit f956412

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

.github/workflows/test-apt-repo.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Test APT repository
22

3-
on:
3+
"on":
44
push:
55
branches:
66
- apt-test
@@ -24,10 +24,17 @@ jobs:
2424
matrix:
2525
package: [defguard, defguard-proxy, defguard-gateway]
2626
component: [release, pre-release]
27+
include:
28+
- package: defguard
29+
github_repo: DefGuard/defguard
30+
- package: defguard-proxy
31+
github_repo: DefGuard/proxy
32+
- package: defguard-gateway
33+
github_repo: DefGuard/gateway
2734

2835
steps:
2936
- name: Install prerequisites
30-
run: apt-get update -y && apt-get install -y ca-certificates curl libmnl0
37+
run: apt-get update -y && apt-get install -y ca-certificates curl jq libmnl0
3138

3239
- name: Add Defguard GPG key
3340
run: |
@@ -43,8 +50,35 @@ jobs:
4350
- name: Update APT cache
4451
run: apt-get update -y
4552

53+
- name: Get expected version from GitHub
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
if [ "${{ matrix.component }}" = "release" ]; then
58+
VERSION=$(curl -sf \
59+
-H "Authorization: Bearer $GH_TOKEN" \
60+
https://api.github.com/repos/${{ matrix.github_repo }}/releases/latest \
61+
| jq -r '.tag_name')
62+
else
63+
VERSION=$(curl -sf \
64+
-H "Authorization: Bearer $GH_TOKEN" \
65+
https://api.github.com/repos/${{ matrix.github_repo }}/releases \
66+
| jq -r '[.[] | select(.prerelease == true)][0].tag_name')
67+
fi
68+
VERSION="${VERSION#v}"
69+
echo "Expected version: $VERSION"
70+
echo "EXPECTED_VERSION=$VERSION" >> $GITHUB_ENV
71+
4672
- name: Install ${{ matrix.package }}
4773
run: apt-get install -y ${{ matrix.package }}
4874

49-
- name: Verify ${{ matrix.package }} binary
50-
run: ${{ matrix.package }} -V
75+
- name: Verify ${{ matrix.package }} version
76+
run: |
77+
INSTALLED=$(dpkg -s ${{ matrix.package }} | grep '^Version:' | awk '{print $2}')
78+
echo "Installed version: $INSTALLED"
79+
echo "Expected version: $EXPECTED_VERSION"
80+
if [ "$INSTALLED" != "$EXPECTED_VERSION" ]; then
81+
echo "Version mismatch!"
82+
exit 1
83+
fi
84+
${{ matrix.package }} -V

0 commit comments

Comments
 (0)