diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index a53772b..c5069ba 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -195,6 +195,6 @@ jobs:
- name: Download and test
run: |
- mvn clean test -Dh3.github.artifacts.use=true -Dh3.github.artifacts.ref=${{ github.sha }}
+ mvn clean test -Dh3.github.artifacts.use=true -Dh3.github.artifacts.by_run=${{ github.run_id }}
env:
GH_TOKEN: ${{ github.token }}
diff --git a/pom.xml b/pom.xml
index 5b15b64..f8851db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,7 +73,7 @@
false
20210624-de7b1b0
false
-
+
@@ -271,7 +271,7 @@
${h3.system.prune}
${h3.dockcross.tag}
${h3.github.artifacts.use}
- ${h3.github.artifacts.ref}
+ ${h3.github.artifacts.by_run}
diff --git a/src/main/c/h3-java/build-h3.sh b/src/main/c/h3-java/build-h3.sh
index 6eee7fa..660951c 100755
--- a/src/main/c/h3-java/build-h3.sh
+++ b/src/main/c/h3-java/build-h3.sh
@@ -28,7 +28,7 @@
# github-artifacts - When set, all build artifacts are retrieved from Github
# Actions artifacts rather than built locally (overrides
# all other settings.)
-# github-artifacts-ref - When set, override the default revision to pull artifacts from
+# github-artifacts-run - When set, override the default revision to pull artifacts from
# for `github-artifacts`.
#
# This script downloads H3, builds H3 and the H3-Java native library, and
@@ -45,10 +45,10 @@ USE_DOCKER=$3
SYSTEM_PRUNE=$4
DOCKCROSS_TAG=$5
GITHUB_ARTIFACTS=$6
-GITHUB_ARTIFACTS_REF=$7
+GITHUB_ARTIFACTS_RUN=$7
if $GITHUB_ARTIFACTS; then
- src/main/c/h3-java/pull-from-github.sh "$GITHUB_ARTIFACTS_REF"
+ src/main/c/h3-java/pull-from-github.sh "$GITHUB_ARTIFACTS_RUN"
# The build of the library below is still needed for the binding-functions file
fi
diff --git a/src/main/c/h3-java/pull-from-github.sh b/src/main/c/h3-java/pull-from-github.sh
index 4d07d9d..d409e47 100755
--- a/src/main/c/h3-java/pull-from-github.sh
+++ b/src/main/c/h3-java/pull-from-github.sh
@@ -24,24 +24,27 @@
set -eox pipefail
-GITHUB_ARTIFACTS_REF=$1
+GITHUB_ARTIFACTS_RUN=$1
-if [ -z "$GITHUB_ARTIFACTS_REF" ]; then
- GIT_REVISION=$(git rev-parse HEAD)
-else
- GIT_REVISION="$GITHUB_ARTIFACTS_REF"
-fi
EXTRACT_TO=src/main/resources
-echo downloading artifacts for $GIT_REVISION
-
mkdir -p target
pushd target
-TO_DOWNLOAD=$(gh api \
+ARTIFACTS_LIST=$(gh api \
-H "Accept: application/vnd.github+json" \
- /repos/{owner}/{repo}/actions/artifacts \
- | jq ".artifacts[] | select(.workflow_run.head_sha == \"$GIT_REVISION\")")
+ /repos/{owner}/{repo}/actions/artifacts)
+
+if [ -z "$GITHUB_ARTIFACTS_RUN" ]; then
+ GIT_REVISION=$(git rev-parse HEAD)
+ echo "downloading artifacts for sha $GIT_REVISION"
+ TO_DOWNLOAD=$(echo "$ARTIFACTS_LIST" \
+ | jq ".artifacts[] | select(.workflow_run.head_sha == \"$GIT_REVISION\")")
+else
+ echo "downloading artifacts for run $GITHUB_ARTIFACTS_RUN"
+ TO_DOWNLOAD=$(echo "$ARTIFACTS_LIST" \
+ | jq ".artifacts[] | select(.workflow_run.id == \"$GITHUB_ARTIFACTS_RUN\")")
+fi
echo $TO_DOWNLOAD | jq -c '.' | while read artifactline; do
ARTIFACT_NAME=$(echo $artifactline | jq -r .name)