Skip to content

Reaper Checks

Reaper Checks #136

name: Reaper Checks
on:
schedule:
# Runs every night at midnight (UTC)
- cron: '0 0 * * *'
permissions:
contents: write
jobs:
check-reaper-version:
runs-on: ubuntu-latest
outputs:
latest_version: ${{ steps.get_version.outputs.latest_version }}
sdk_update_needed: ${{ steps.check_for_sdk_update.outputs.sdk_update_needed }}
reaper_flake_input_update_needed: ${{ steps.check_for_reaper_flake_input_update.outputs.reaper_flake_input_update_needed }}
sdk_branch_exists: ${{ steps.check_reaper_sdk_branch.outputs.sdk_branch_exists }}
rs_branch_exists: ${{ steps.check_reascript_rs_branch.outputs.rs_branch_exists }}
steps:
- name: Get latest Reaper release version
id: get_version
run: |
# Extract the full version number from the download page.
# The way we do this is a bit brittle and could break in the future
# should the website be updated. Currently we look for `REAPER X.XX`
# since looking for `REAPER vX.XX` returns multiple matches.
latest_version=$(curl -s https://www.reaper.fm/download.php | grep -oP 'REAPER \K[0-9.]+')
echo "Latest version: $latest_version"
echo "::set-output name=latest_version::$latest_version"
- name: Check if sdk update is needed
id: check_for_sdk_update
run: |
# Extract the full version number from the generated header file
# and compare it to the latest version on reaper.fm download page.
current_version=$(curl -s https://raw.githubusercontent.com/justinfrankel/reaper-sdk/main/sdk/reaper_plugin_functions.h | grep -oP '// Generated by REAPER v\K[0-9]+(\.[0-9]+)+' || echo "Current Version Not Found")
echo "Current version: $current_version"
latest_version=${{ steps.get_version.outputs.latest_version }}
if [[ "$(printf '%s\n' "$current_version" "$latest_version" | sort -V | head -n 1)" != "$latest_version" ]]; then
echo "Update needed"
echo "::set-output name=sdk_update_needed::true"
else
echo "No update needed"
echo "::set-output name=sdk_update_needed::false"
fi
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if reaper flake input update is needed
id: check_for_reaper_flake_input_update
run: |
# Extract the full version number from the current flake.nix file
# and compare it to the latest version on reaper.fm download page.
# The version syntax in this case is 'XXX' with no '.' separation.
current_version=$(grep -oP 'reaper\K([0-9])+' ./flake.nix)
echo "Current version: $current_version"
raw_latest_version=${{ steps.get_version.outputs.latest_version }}
latest_version=${raw_latest_version//./} # remove the '.'
if [[ "$(printf '%s\n' "$current_version" "$latest_version" | sort -V | head -n 1)" != "$latest_version" ]]; then
echo "Update needed"
echo "::set-output name=reaper_flake_input_update_needed::true"
else
echo "No update needed"
echo "::set-output name=reaper_flake_input_update_needed::false"
fi
- name: Check if reaper-sdk branch exists
id: check_reaper_sdk_branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch_name="update-header-${{ steps.get_version.outputs.latest_version }}"
api_url="https://api.github.com/repos/Cloud-Scythe-Labs/reaper-sdk/branches/${branch_name}"
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITHUB_TOKEN" "$api_url")
if [[ "$response" == "200" ]]; then
echo "Branch $branch_name already exists"
echo "::set-output name=sdk_branch_exists::true"
else
echo "Branch $branch_name does not exist"
echo "::set-output name=sdk_branch_exists::false"
fi
- name: Check if reascript-rs branch exists
id: check_reascript_rs_branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch_name="update-reaper-flake-input-${{ steps.get_version.outputs.latest_version }}"
api_url="https://api.github.com/repos/Cloud-Scythe-Labs/reascript-rs/branches/${branch_name}"
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITHUB_TOKEN" "$api_url")
if [[ "$response" == "200" ]]; then
echo "Branch $branch_name already exists"
echo "::set-output name=rs_branch_exists::true"
else
echo "Branch $branch_name does not exist"
echo "::set-output name=rs_branch_exists::false"
fi
update_reaper_tarball_url:
runs-on: ubuntu-latest
needs: check-reaper-version
if: ${{ needs.check-reaper-version.outputs.reaper_flake_input_update_needed == 'true' && needs.check-reaper-version.outputs.rs_branch_exists == 'false' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Nix
uses: cachix/install-nix-action@v17
- name: Update REAPER tarball URL
run: |
nix develop -c update_reaper_flake_input.sh
nix flake update reaper
- name: Commit and push changes
run: |
latest_version=${{ needs.check-reaper-version.outputs.latest_version }}
git config --global user.email "cloudscythelabs@gmail.com"
git config --global user.name "Cloud Scythe Labs"
git remote set-url origin "https://x-access-token:${{ secrets.REASCRIPT_PULL_REQUEST }}@github.com/Cloud-Scythe-Labs/reascript-rs.git"
git checkout -b update-reaper-flake-input-${latest_version}
git add -u
git commit -m "Update Reaper tarball URL ${latest_version}"
git push origin update-reaper-flake-input-${latest_version}
pull_request_res=$(curl -X POST -H "Authorization: token ${{ secrets.REASCRIPT_PULL_REQUEST }}" \
-d '{
"title": "Update Reaper tarball URL ${{ needs.check-reaper-version.outputs.latest_version }}",
"body": "automated update of the reaper tarball URL.",
"head": "update-reaper-flake-input-${{ needs.check-reaper-version.outputs.latest_version }}",
"base": "master"
}' \
https://api.github.com/repos/Cloud-Scythe-Labs/reascript-rs/pulls)
if [[ "$pull_request_res" =~ "nothing to commit" ]]; then
exit 0
fi
generate-reaper-plugin-functions:
runs-on: ubuntu-latest
needs: check-reaper-version
if: ${{ needs.check-reaper-version.outputs.sdk_update_needed == 'true' && needs.check-reaper-version.outputs.sdk_branch_exists == 'false' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Nix
uses: cachix/install-nix-action@v17
- name: Clone reaper-sdk fork
run: |
mkdir temp
cd temp
git clone https://github.com/Cloud-Scythe-Labs/reaper-sdk.git
- name: Generate header file
run: |
latest_version=${{ needs.check-reaper-version.outputs.latest_version }}
nix build .#reaper-plugin-functions
cp result/include/reaper_plugin_functions.h temp/reaper-sdk/sdk/reaper_plugin_functions.h
generated_version=$(cat temp/reaper-sdk/sdk/reaper_plugin_functions.h | grep -oP '// Generated by REAPER v\K[0-9]+(\.[0-9]+)+' || echo "Current Version Not Found")
if [[ "$generated_version" != "$latest_version" ]]; then
echo "Expected version '$latest_version' but the generated version is '$generated_version'"
exit 1
fi
- name: Commit and push changes
run: |
latest_version=${{ needs.check-reaper-version.outputs.latest_version }}
git config --global user.email "cloudscythelabs@gmail.com"
git config --global user.name "Cloud Scythe Labs"
cd temp/reaper-sdk/sdk
git remote -v
git status
git remote set-url origin "https://x-access-token:${{ secrets.REASCRIPT_PULL_REQUEST }}@github.com/Cloud-Scythe-Labs/reaper-sdk.git"
git checkout -b update-header-${latest_version}
git add reaper_plugin_functions.h
git commit -m "Update Reaper C++ API functions header to version ${latest_version}"
git push origin update-header-${latest_version}
curl -X POST -H "Authorization: token ${{ secrets.REASCRIPT_PULL_REQUEST }}" \
-d '{
"title": "Update Reaper C++ API functions header to version ${{ needs.check-reaper-version.outputs.latest_version }}",
"body": "Automated update of the Reaper C++ API functions header.",
"head": "Cloud-Scythe-Labs:update-header-${{ needs.check-reaper-version.outputs.latest_version }}",
"base":"main"
}' \
https://api.github.com/repos/justinfrankel/reaper-sdk/pulls