Skip to content

Add CBMC formula

Add CBMC formula #231

Workflow file for this run

name: Add CBMC formula
on:
schedule:
- cron: "0 */6 * * *" # Run this every 6 hours
workflow_dispatch: # Allow manual dispatching for a custom branch / tag.
permissions:
checks: write
contents: write
pull-requests: write
jobs:
create-formula-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Obtain latest CBMC release
env:
GH_TOKEN: ${{ github.token }}
run: |
CBMC_LATEST=$(gh -R diffblue/cbmc release list | grep Latest | awk '{print $1}' | cut -f2 -d-)
echo "CBMC_LATEST: ${CBMC_LATEST}"
echo "CBMC_LATEST=${CBMC_LATEST}" >> "${GITHUB_ENV}"
# check whether we already have the formula
if [ -e "Formula/cbmc@${CBMC_LATEST}.rb" ] ; then
echo "Formula already exists"
echo "next_step=none" >> "${GITHUB_ENV}"
# check whether we already have a PR for the formula
elif git ls-remote --exit-code origin "cbmc-${CBMC_LATEST}" ; then
echo "Branch cbmc-${CBMC_LATEST} already exists"
echo "next_step=none" >> "${GITHUB_ENV}"
else
CBMC_LATEST_REV=$(gh -R diffblue/cbmc release view cbmc-"${CBMC_LATEST}" --json targetCommitish | jq -r '.targetCommitish')
echo "CBMC_LATEST_REV: ${CBMC_LATEST_REV}"
echo "CBMC_LATEST_REV=${CBMC_LATEST_REV}" >> "${GITHUB_ENV}"
echo "next_step=check_brew" >> "${GITHUB_ENV}"
fi
- name: Set up Homebrew
if: ${{ env.next_step == 'check_brew' }}
uses: Homebrew/actions/setup-homebrew@master
- name: Check CBMC version in brew
if: ${{ env.next_step == 'check_brew' }}
run: |
brew update
CBMC_BREW=$(brew info cbmc --json | jq -r '.[0].versions.stable')
echo "CBMC_BREW: ${CBMC_BREW}"
if [ "${CBMC_BREW}" = "${CBMC_LATEST}" ] ; then
formula_base=$(find Formula/ -type f | sort | tail -1)
sed '/bottle do/Q' "${formula_base}" > "Formula/cbmc@${CBMC_LATEST}.rb"
sed -i "1s/CbmcAT[[:digit:]]*/CbmcAT${CBMC_LATEST//./}/" "Formula/cbmc@${CBMC_LATEST}.rb"
sed -i "5s/\".*\"/\"cbmc-${CBMC_LATEST}\"/" "Formula/cbmc@${CBMC_LATEST}.rb"
sed -i "6s/\".*\"/\"cbmc-${CBMC_LATEST_REV}\"/" "Formula/cbmc@${CBMC_LATEST}.rb"
./transform_binary.sh "${CBMC_LATEST}" >> "Formula/cbmc@${CBMC_LATEST}.rb"
sed -n '1,/end$/!p' "${formula_base}" >> "Formula/cbmc@${CBMC_LATEST}.rb"
echo "next_step=upload_and_create_pr" >> "${GITHUB_ENV}"
else
echo "next_step=none" >> "${GITHUB_ENV}"
fi
- name: Upload bottles
if: ${{ env.next_step == 'upload_and_create_pr' }}
uses: softprops/action-gh-release@v2
with:
tag_name: bag-of-goodies
files: cbmc@*.tar.gz
- name: Create Pull Request
if: ${{ env.next_step == 'upload_and_create_pr' }}
uses: peter-evans/create-pull-request@v7
with:
commit-message: Add formula for CBMC ${{ env.CBMC_LATEST }}
add-paths: Formula/cbmc@*.rb
branch: cbmc-${{ env.CBMC_LATEST }}
delete-branch: true
title: 'Add formula for CBMC ${{ env.CBMC_LATEST }}'
body: >
Add brew formula for CBMC's latest release.