Skip to content
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

Add script for updating Reaper packages #20

Merged
merged 34 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9ec41f0
add update script for x86_64
andrewvious Sep 3, 2024
fbcdd8a
fix bad sub in script, add default.nix that is generated
andrewvious Sep 4, 2024
66cbbf2
rm redundant string interpolation
andrewvious Sep 4, 2024
622bb97
fmt default.nix & reflect fmt in update script
andrewvious Sep 4, 2024
b1ef511
fix script to expand on variables given
andrewvious Sep 4, 2024
118b92c
fmt default.nix & reflect fmt in update script
andrewvious Sep 4, 2024
755936c
rework update script to print tarball link & hash
andrewvious Sep 4, 2024
00ff181
rework update script to update reaper url in flake.nix
andrewvious Sep 5, 2024
46fdd96
rm shell script, convert to nix module
andrewvious Sep 6, 2024
a434ddf
Merge branch 'master' into andrewvious/19
andrewvious Sep 6, 2024
fa41076
update nix module, add input for nix mod in flake.nix, add ci workflo…
andrewvious Sep 6, 2024
cb641bb
fix ci workflow logic
andrewvious Sep 6, 2024
5af9f35
fmt flake.nix
andrewvious Sep 6, 2024
f9f7f23
fix yml
andrewvious Sep 6, 2024
06f3900
swap from cron to on pull for testing
andrewvious Sep 7, 2024
1bde3b9
update yml & modify tarball url for ci testing
andrewvious Sep 7, 2024
0b6da72
Update Reaper tarball URL 7.22 (#22)
eureka-cpu Sep 7, 2024
8a8fecf
add conditional check for nothing to commit
andrewvious Sep 7, 2024
060b1dc
add regex to nothing to commit check
andrewvious Sep 7, 2024
b30e2ed
update regex syntax
andrewvious Sep 7, 2024
5335ef9
try grep instead of regex
andrewvious Sep 7, 2024
c64d436
add debug for pull req res
andrewvious Sep 7, 2024
5a9db1f
test pull request fails
andrewvious Sep 7, 2024
b5be29a
rename updates for sdk in yml
andrewvious Sep 7, 2024
4fbf3b4
test workflow version check for rs
andrewvious Sep 7, 2024
c9f432e
test flake.nix path for grep
andrewvious Sep 7, 2024
9651f2a
add debugging to find flake.nix
andrewvious Sep 7, 2024
e7500be
rm debug ls
andrewvious Sep 7, 2024
119b4e5
change regex grep to account for larger version numbers, and rm on pu…
andrewvious Sep 7, 2024
1baf1d6
update name of reaper flake input check
andrewvious Sep 7, 2024
f75583f
modify imports for update.sh
andrewvious Sep 7, 2024
1082d4f
mv update.nix to scripts dir
andrewvious Sep 8, 2024
351e775
rename update.nix, update flake/yml accordingly
andrewvious Sep 8, 2024
caaec39
rename again for better readability
andrewvious Sep 8, 2024
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
103 changes: 92 additions & 11 deletions .github/workflows/generate_reaper_plugin_functions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Reaper Checks
on:
schedule:
# Runs every night at midnight (UTC)
Expand All @@ -11,8 +12,10 @@ jobs:
runs-on: ubuntu-latest
outputs:
latest_version: ${{ steps.get_version.outputs.latest_version }}
update_needed: ${{ steps.check_for_update.outputs.update_needed }}
branch_exists: ${{ steps.check_branch.outputs.branch_exists }}
sdk_update_needed: ${{ steps.check_for_sdk_update.outputs.sdk_update_needed }}
rs_update_needed: ${{ steps.check_for_rs_update.outputs.rs_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
Expand All @@ -25,8 +28,8 @@ jobs:
echo "Latest version: $latest_version"
echo "::set-output name=latest_version::$latest_version"

- name: Check if update is needed
id: check_for_update
- 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.
Expand All @@ -35,14 +38,36 @@ jobs:
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=update_needed::true"
echo "::set-output name=sdk_update_needed::true"
else
echo "No update needed"
echo "::set-output name=update_needed::false"
echo "::set-output name=sdk_update_needed::false"
fi

- name: Checkout repository
uses: actions/checkout@v2

- name: Check if rs update is needed
andrewvious marked this conversation as resolved.
Show resolved Hide resolved
id: check_for_rs_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 '.'

- name: Check if branch exists
id: check_branch
if [[ "$(printf '%s\n' "$current_version" "$latest_version" | sort -V | head -n 1)" != "$latest_version" ]]; then
echo "Update needed"
echo "::set-output name=rs_update_needed::true"
else
echo "No update needed"
echo "::set-output name=rs_update_needed::false"
fi

- name: Check if reaper-sdk branch exists
id: check_reaper_sdk_branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand All @@ -51,16 +76,72 @@ jobs:
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=branch_exists::true"
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=branch_exists::false"
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.rs_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.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.update_needed == 'true' && needs.check-reaper-version.outputs.branch_exists == 'false' }}
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
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
devShells.default = craneLib.devShell {
checks = self.checks.${system};
packages = with pkgs; [
(pkgs.callPackage ./lib/update.nix { })
nil
nixpkgs-fmt
] ++ rustToolchain.complete;
Expand Down
47 changes: 47 additions & 0 deletions lib/update.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ pkgs, ... }:
andrewvious marked this conversation as resolved.
Show resolved Hide resolved
pkgs.writeShellScriptBin "update.sh" ''
set -euo pipefail

latest_version=$(curl -s https://www.reaper.fm/download.php | grep -oP 'REAPER \K[0-9.]+')

function update_nix_flake() {
local flake="$1"

file_tag=''${latest_version%%.*} # retain only the major version
reap_tag=''${latest_version//./} # remove the '.'
reap_tar="reaper''${reap_tag}_linux_x86_64.tar.xz"
reaper_tarball_link="https://www.reaper.fm/files/''${file_tag}.x/''${reap_tar}"

echo "Updating REAPER tarball URL to: ''${reaper_tarball_link}"

awk -v new_url="$reaper_tarball_link" '
BEGIN { url_updated = 0 }
{
if ($0 ~ /reaper\s*=\s*\{/ && url_updated == 0) {
print
while (getline) {
if ($0 ~ /url\s*=/) {
sub(/url\s*=\s*"[^"]*"/, "url = \"" new_url "\"")
url_updated = 1
}
print
if ($0 ~ /}/) {
break
}
}
} else {
print
}
}
' "$flake" > "''${flake}.tmp" && mv "''${flake}.tmp" "$flake"
}

nix_flake="$(pwd)/flake.nix"

if [ ! -f "$nix_flake" ]; then
echo "Error: $nix_flake does not exist."
exit 1
fi

update_nix_flake "$nix_flake"
''