Skip to content

Commit ea92c22

Browse files
authored
Add scripts for automatically updating K Nighly, opening PR into repo (#503)
* Makefile, include.mk: hardcode the nightly URL used * scripts/update-k-nightly.sh: script for automatically updating the K nightly release version * scripts/update-k-nightly-pr.sh: script to also open the PR for you * scripts/update-k-nightly-pr: upstream branch, not remote * scripts/update-k-nightly-pr: also specify reviewer to use
1 parent d6e46a1 commit ea92c22

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ kore-exec: $(KORE_EXEC)
1111
k-frontend:
1212
mkdir -p $(BUILD_DIR)
1313
rm -rf $(K_DIST_DEFAULT) $(K_NIGHTLY)
14-
curl --location --output $(K_NIGHTLY) \
15-
$$(curl 'https://api.github.com/repos/kframework/k/releases' | jq --raw-output '.[${K_NIGHTLY_OFFSET}].assets[].browser_download_url | match(".*nightly.tar.gz").string')
14+
curl --location --output $(K_NIGHTLY) $(K_NIGHTLY_URL)
1615
mkdir -p $(K_DIST_DEFAULT)
1716
tar --extract --file $(K_NIGHTLY) --strip-components 1 --directory $(K_DIST_DEFAULT)
1817
$(KRUN) --version

include.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ UPSTREAM_BRANCH = origin/master
55

66
BUILD_DIR = $(TOP)/.build
77
K_NIGHTLY = $(BUILD_DIR)/nightly.tar.gz
8-
K_NIGHTLY_OFFSET ?= 0
8+
K_NIGHTLY_URL = https://github.com/kframework/k/releases/download/nightly-4375ba02b/nightly.tar.gz
99
K_DIST_DEFAULT = $(BUILD_DIR)/k
1010
K_DIST ?= $(K_DIST_DEFAULT)
1111
K_DIST_BIN = $(K_DIST)/bin

scripts/update-k-nightly-pr.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
set -exuo pipefail
4+
5+
export TOP=${TOP:-$(git rev-parse --show-toplevel)}
6+
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-origin}
7+
UPSTREAM_BRANCH=master
8+
BRANCH_NAME=update-k-nightly
9+
10+
$TOP/scripts/git-assert-clean.sh
11+
12+
if [[ $(git rev-parse HEAD) != $(git rev-parse $UPSTREAM_BRANCH) ]]; then
13+
echo "Must run with $UPSTREAM_BRANCH checked out!!!"
14+
exit 1
15+
fi
16+
17+
$TOP/scripts/update-k-nightly.sh
18+
19+
if $TOP/scripts/git-assert-clean.sh; then
20+
echo "No update..."
21+
exit 0
22+
fi
23+
24+
git checkout -B "$BRANCH_NAME" "$UPSTREAM_REMOTE/$UPSTREAM_BRANCH"
25+
26+
git add $TOP/include.mk
27+
28+
git commit --message 'include.mk: update K nightly version'
29+
30+
hub pull-request --push --force --head "$BRANCH_NAME" --base "$UPSTREAM_BRANCH" --reviewer ehildenb --file - <<MSG
31+
Update K Nightly version used for integration testing
32+
33+
PR generated by '$0'
34+
MSG

scripts/update-k-nightly.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -exuo pipefail
4+
5+
export TOP=${TOP:-$(git rev-parse --show-toplevel)}
6+
7+
new_nightly="$(curl 'https://api.github.com/repos/kframework/k/releases' | jq --raw-output '.[0].assets[].browser_download_url | match(".*nightly.tar.gz").string')"
8+
9+
sed -i '/K_NIGHTLY_URL.*/c\'"K_NIGHTLY_URL = $new_nightly" "$TOP/include.mk"

0 commit comments

Comments
 (0)