diff --git a/.github/actions/setup-swig/action.yml b/.github/actions/setup-swig/action.yml new file mode 100644 index 0000000000..0eb8a04473 --- /dev/null +++ b/.github/actions/setup-swig/action.yml @@ -0,0 +1,20 @@ +name: Set up SWIG +description: | + Download and build SWIG and set the SWIG environment variable to the path of + the SWIG executable. + +inputs: + swig_version: + description: 'Swig version to build' + required: false + default: '4.1.1' + +runs: + using: "composite" + steps: + - name: Download and build SWIG + run: scripts/downloadAndBuildSwig.sh + shell: bash + + - run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-${{ inputs.swig_version }}/install/bin/swig" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/deploy_branch.yml b/.github/workflows/deploy_branch.yml index 77883907d3..73294286a1 100644 --- a/.github/workflows/deploy_branch.yml +++ b/.github/workflows/deploy_branch.yml @@ -21,12 +21,10 @@ jobs: with: fetch-depth: 20 - - run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV - - run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-4.0.1/install/bin/swig" >> $GITHUB_ENV + - name: Set up SWIG + uses: ./.github/actions/setup-swig - - name: Build swig4 - run: | - sudo scripts/downloadAndBuildSwig.sh + - run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV - name: Create AMICI sdist run: | diff --git a/.github/workflows/deploy_release.yml b/.github/workflows/deploy_release.yml index ce493533e7..001d0328bf 100644 --- a/.github/workflows/deploy_release.yml +++ b/.github/workflows/deploy_release.yml @@ -24,12 +24,10 @@ jobs: with: fetch-depth: 20 - - run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV - - run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-4.0.1/install/bin/swig" >> $GITHUB_ENV + - name: Set up SWIG + uses: ./.github/actions/setup-swig - - name: Build swig4 - run: | - sudo scripts/downloadAndBuildSwig.sh + - run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV - name: sdist run: | diff --git a/.github/workflows/test_doc.yml b/.github/workflows/test_doc.yml index 98c023ba79..2190e8528c 100644 --- a/.github/workflows/test_doc.yml +++ b/.github/workflows/test_doc.yml @@ -68,7 +68,6 @@ jobs: - run: git fetch --prune --unshallow - run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV - - run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-4.1.1/install/bin/swig" >> $GITHUB_ENV - name: Build doxygen run: | @@ -85,9 +84,7 @@ jobs: pandoc \ python3-venv \ - - name: Build swig - run: | - sudo scripts/downloadAndBuildSwig.sh + - uses: ./.github/actions/setup-swig - name: sphinx run: | diff --git a/scripts/downloadAndBuildSwig.sh b/scripts/downloadAndBuildSwig.sh index b7d7f9d865..5fa0896f6c 100755 --- a/scripts/downloadAndBuildSwig.sh +++ b/scripts/downloadAndBuildSwig.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash # Download and build SWIG -set -e +# +# Usage: downloadAndBuildSwig.sh [swig_version] +set -euo pipefail SCRIPT_PATH=$(dirname "$BASH_SOURCE") AMICI_PATH=$(cd "$SCRIPT_PATH/.." && pwd) -swig_version=4.1.1 +swig_version="${1:-"4.1.1"}" SWIG_ARCHIVE="swig-${swig_version}.tar.gz" SWIG_URL="http://downloads.sourceforge.net/project/swig/swig/swig-${swig_version}/${SWIG_ARCHIVE}" SWIG_DIR="swig-${swig_version}"