diff --git a/.github/actions/compile_inchi_lib/action.yaml b/.github/actions/compile_inchi_lib/action.yaml index 1cf8b31..499fd79 100644 --- a/.github/actions/compile_inchi_lib/action.yaml +++ b/.github/actions/compile_inchi_lib/action.yaml @@ -1,4 +1,4 @@ -name: Compile InChI library from triggering branch +name: Compile InChI library from triggering commit runs: using: "composite" @@ -6,12 +6,10 @@ runs: - run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" # https://github.com/actions/runner-images/issues/6775 mkdir "$GITHUB_WORKSPACE/$LIB_DIR" - ./INCHI-1-TEST/compile_inchi_lib.sh $BRANCH "$GITHUB_WORKSPACE/$LIB_DIR" - if [ "$BRANCH" != "main" ]; then - # Rename library to libinchi.so.main, since that's the name the tests expect. - mv "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.$BRANCH" "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.main" - fi + ./INCHI-1-TEST/compile_inchi_lib.sh $COMMIT "$GITHUB_WORKSPACE/$LIB_DIR" + # Rename library to libinchi.so.main, since that's the name the tests expect. + mv "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.$COMMIT" "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.main" shell: bash env: - BRANCH: ${{ github.ref_name }} + COMMIT: ${{ github.sha }} LIB_DIR: INCHI-1-TEST/libs diff --git a/INCHI-1-TEST/compile_inchi_lib.sh b/INCHI-1-TEST/compile_inchi_lib.sh index 2944a93..e9db1ba 100755 --- a/INCHI-1-TEST/compile_inchi_lib.sh +++ b/INCHI-1-TEST/compile_inchi_lib.sh @@ -2,7 +2,7 @@ set -e -inchi_version=$1 # Must be one of the tags in `git tag` or branches in `git branch`. +inchi_version=$1 # Must be one of the tags in `git tag`, branches in `git branch`, or a commit hash. inchi_lib_dir=$2 # Path must be absolute. current_branch=$(git rev-parse --abbrev-ref HEAD) makefile_dir="INCHI-1-SRC/INCHI_API/libinchi/gcc" @@ -24,7 +24,6 @@ if [ -n "$(git status --porcelain)" ]; then exit 1 fi -# Check out the specified tag or branch. if git rev-parse --verify --quiet refs/tags/$inchi_version; then echo "Checking out version tag '$inchi_version'." git checkout "tags/$inchi_version" @@ -32,13 +31,13 @@ if git rev-parse --verify --quiet refs/tags/$inchi_version; then fi if git rev-parse --verify --quiet $inchi_version; then - echo "Checking out branch '$inchi_version'." + echo "Checking out branch or commit '$inchi_version'." git checkout $inchi_version checkout_successful=1 fi if [ $checkout_successful -eq 0 ]; then - echo "Version tag or branch '$inchi_version' does not exist." + echo "'$inchi_version' does not exist." exit 1 fi