Skip to content

Commit 6572be6

Browse files
committed
get release version
1 parent 5778720 commit 6572be6

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

java/ql/automodel/publish.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
11
#!/bin/sh
22
set -e
33

4-
# Before running this, make sure there is an SSO-enabled token with package:write
5-
# permissions to codeql supplied via the GITHUB_TOKEN environment variable
4+
# Before running this, make sure
5+
# 1. there is an SSO-enabled token with package:write permissions to codeql supplied via the GITHUB_TOKEN environment variable
6+
# 2. the CODEQL_DIST environment variable is set to the path of a codeql distribution
7+
# 3. the gh command line tool is installed and authenticated with a token that has repo permissions to github/codeml-automodel
8+
# supplied via the GH_TOKEN environment variable
9+
10+
# Script to publish a new version of the automodel package to the package registry.
11+
# Usage: ./publish [override-release]
12+
# By default the sha of the codeql repo specified in the latest release of codeml-automodel will be published.
13+
# Otherwise, the optional argument override-release forces the current HEAD to be published.
14+
15+
# If the first argument is empty, use the latest release of codeml-automodel
16+
if [ -z "${1:-}" ]; then
17+
TAG_NAME=$(gh api -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' /repos/github/codeml-automodel/releases/latest | jq -r .tag_name)
18+
# Check TAG_NAME is not empty
19+
if [ -z "$TAG_NAME" ]; then
20+
echo "Error: Could not get latest release of codeml-automodel"
21+
exit 1
22+
fi
23+
echo "Updating to latest automodel release: $TAG_NAME"
24+
rm release.zip || true
25+
gh release download $TAG_NAME -A zip -O release.zip --repo 'https://github.com/github/codeml-automodel'
26+
unzip -o release.zip -d release
27+
REVISION=$(jq -r '.["codeql-sha"]' release/codeml-automodel*/codeml-automodel-release.json)
28+
echo "The latest automodel release specifies a codeql revision of $REVISION"
29+
if git diff --quiet; then
30+
echo "Checking out CodeQL revision $REVISION"
31+
git reset --hard "$REVISION"
32+
else
33+
echo "Error: Uncommitted changes exist. Please commit or stash your changes before resetting."
34+
exit 1
35+
fi
36+
fi
637

738
AUTOMODEL_ROOT="$(readlink -f "$(dirname $0)")"
839
WORKSPACE_ROOT="$AUTOMODEL_ROOT/../../.."

0 commit comments

Comments
 (0)