Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:44

0001 #!/bin/bash
0002 set -e
0003 set -u
0004 
0005 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
0006 export GIT_CLIFF_CONFIG=$SCRIPT_DIR/cliff.toml
0007 
0008 # helper function to selectively print and run commands without a subshell
0009 function run() {
0010     set -x
0011     "$@"
0012     # save exit code
0013     { rec=$?; } 2> /dev/null
0014     { set +x;   } 2> /dev/null
0015     # restore exit code
0016     (exit $rec)
0017 }
0018 
0019 export run
0020 
0021 version=$(git cliff --bumped-version)
0022 echo "Bumped version will be: $version"
0023 
0024 zenodo=$(cat .zenodo.json)
0025 echo "$zenodo" \
0026   | jq --arg version "$version" '.version = $version' \
0027   | jq --arg version "$version" '.title = "acts-project/acts: \($version)"' \
0028   > .zenodo.json
0029 echo "- Updated .zenodo.json"
0030 
0031 citation=$(cat CITATION.cff)
0032 echo "$citation" \
0033   | sed "s/^version: .*/version: $version/" \
0034   > CITATION.cff
0035 echo "- Updated CITATION.cff"
0036 
0037 echo "$version" | sed 's/^v//g' > version_number
0038 echo "- Updated version_bumber"
0039 
0040 run git add .zenodo.json CITATION.cff version_number
0041 run git commit -n -m"Bump version to $version"
0042 CI=${CI:-}
0043 if [ -n "$CI" ]; then
0044   run git push
0045 fi
0046 
0047 run git cliff --tag "$version" --latest --unreleased -o release.md
0048 
0049 RELEASE_TARGET=${RELEASE_TARGET:-$(git rev-parse HEAD)}
0050 
0051 set +e
0052 ! gh release view "$version" > /dev/null 2>&1
0053 release_exists=$?
0054 set -e
0055 if [[ $release_exists == 1 ]]; then
0056   echo "Release $version exists"
0057   run gh release edit $version \
0058     --notes-file release.md \
0059     --target $RELEASE_TARGET \
0060     --draft
0061 else
0062   echo "Release $version does not exist"
0063   run gh release create $version \
0064     --title "$version" \
0065     --notes-file release.md \
0066     --target $RELEASE_TARGET \
0067     --draft
0068 fi