Skip to content

Add an action to perform automatic releases #5456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/regular-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
- cron: '0 9 * * THU'
# ^ this means 9:00 AM every thursday
# I can’t figure out the right syntax
# for ‘every other thursday’
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually having looked into this a bit more I don't think there is a right syntax for "every other thursday". The cron syntax we have available here is very limited (see: https://crontab.guru/#0_9_*_*_THU)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think Cron syntax supports that - best you can probably do is to run this job every thursday, and then in the job check if it's a release Thursday or not (and short circuit if its not). Might want to think about timezones as well?


jobs:
bump_cbmc_version:
runs-on: ubuntu-20.04
outputs:
cbmc_version: ${{ steps.cbmc_version_number.outputs.CBMC_VERSION }}
bump_git_sha: ${{ steps.commit_bump.outputs.bump_git_sha }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Get new CBMC version number
id: cbmc_version_number
run: |
NEW_CBMC_VERSION=$(grep '^CBMC_VERSION =' src/config.inc | cut -d = -f 2 | scripts/increment_version.sh)
echo ::set-env name=CBMC_VERSION::$NEW_CBMC_VERSION
echo ::set-output name=CBMC_VERSION::$NEW_CBMC_VERSION
- name: Update CBMC version
run: |
sed -i "s/CBMC_VERSION = .*/CBMC_VERSION = $CBMC_VERSION/" src/config.inc
- name: Set git identity to github bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this name still valid after the change?

Copy link
Contributor Author

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, no I need to update the name of this step.

edit github bot is probably the right name for this

run: |
git config --local user.name db-ci-cprover
git config --local user.email "[email protected]"
- name: Commit changes
id: commit_bump
run: |
git commit -a -m "Bump version to $CBMC_VERSION"
echo "::set-output name=bump_git_sha::$(git rev-parse HEAD)"
- name: Push changes
run: |
git push
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Which branch is this pushing to? Might be nice to have a comment with the answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn’t specify a branch in checkout, so we pull from the default (develop), which automatically also sets the upstream of the branch to develop. So this will push against develop.

perform-release:
needs: bump_cbmc_version
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
# We just added a commit to master, so the default GITHUB_REF doesn’t work anymore
ref: master
- name: DEBUG show bump version
run: echo ${{ needs.bump_cbmc_version.outputs.CBMC_VERSION }}
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.DB_CI_CPROVER_ACCESS_TOKEN }}
with:
tag_name: cbmc-${{ needs.bump_cbmc_version.outputs.CBMC_VERSION }}
release_name: cbmc-${{ needs.bump_cbmc_version.outputs.CBMC_VERSION }}
draft: false
prerelease: false
commitish: ${{ needs.bump_cbmc_version.outputs.bump_git_sha }}
7 changes: 7 additions & 0 deletions scripts/increment_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# By default, just create a new minor version. If we ever need to change
# major/patch version just do it manually.
read -r version_line
major=$(echo $version_line | cut -d . -f 1)
minor=$(echo $version_line | cut -d . -f 2)
patch=$(echo $version_line | cut -d . -f 3)
echo "$major.$(expr $minor + 1).0"