-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (69 loc) · 3.03 KB
/
add-formula.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 [ "${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.