-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-extractor-pack.sh
More file actions
executable file
·50 lines (38 loc) · 1.39 KB
/
publish-extractor-pack.sh
File metadata and controls
executable file
·50 lines (38 loc) · 1.39 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
#!/bin/bash
set -e
# Extractor info
EXTRACTOR_INFO="./codeql-extractor.yml"
EXTRACTOR_NAME="${EXTRACTOR_NAME:-$(basename $(dirname $EXTRACTOR_INFO))}"
EXTRACTOR_VERSION=$(grep version $EXTRACTOR_INFO | awk '{print $2}')
LATEST_RELEASE=$(gh release list | head -n 1 | awk '{print $1}' | sed 's/v//')
if which codeql >/dev/null 2>&1; then
CODEQL_BINARY="codeql"
elif gh codeql version >/dev/null 2>&1; then
CODEQL_BINARY="gh codeql"
else
gh extension install github/gh-codeql
CODEQL_BINARY="gh codeql"
fi
echo "[+] ${EXTRACTOR_NAME} (${EXTRACTOR_VERSION})"
echo "[+] Last release: ${LATEST_RELEASE}"
if [ "$LATEST_RELEASE" != "$EXTRACTOR_VERSION" ]; then
echo "[+] New Extractor version being released"
# Check extracrtor-pack
if [ ! -d "extractor-pack" ]; then
echo "[+] No extractor-pack found"
exit 1
fi
echo "[+] Add queries to extractor-pack"
$CODEQL_BINARY pack create --output=./extractor-pack/qlpacks ./ql/lib
$CODEQL_BINARY pack create --output=./extractor-pack/qlpacks ./ql/src
# bundle extractor
tar czf extractor-$EXTRACTOR_NAME.tar.gz extractor-pack
export GH_TOKEN=$GITHUB_TOKEN
ls -ls ./extractor-pack/tools
# create release
gh release create "v$EXTRACTOR_VERSION" \
--notes "$EXTRACTOR_NAME Extractor v$EXTRACTOR_VERSION" \
extractor-$EXTRACTOR_NAME.tar.gz
else
echo "[+] Extractor is up to date"
fi