Skip to content

Add CBMC formula

Add CBMC formula #1

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 "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 [ "x${CBMC_BREW}" = "x${CBMC_LATEST}" ] ; then
formula_base=$(ls Formula | tail -1)
sed '/bottle do/Q' "Formula/${formula_base}" > "Formula/cbmc@${CBMC_LATEST}.rb"
version_no_dot=$(echo "${CBMC_LATEST}" | sed 's/\.//g')
sed -i "1s/CbmcAT[[:digit:]]*/CbmcAT${version_no_dot}/" "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/${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:
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.