name: Bump netbird on: schedule: - cron: "17 */2 * * *" workflow_dispatch: permissions: contents: write jobs: bump: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Update cask to the latest release env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail cask=Casks/netbird-ui.rb latest=$(gh api repos/netbirdio/netbird/releases/latest --jq .tag_name) latest=${latest#v} current=$(sed -nE 's/^ version "([^"]+)"$/\1/p' "$cask") if [ "$latest" = "$current" ]; then echo "Already at $current" exit 0 fi base="https://github.com/netbirdio/netbird/releases/download/v$latest" declare -A sha for asset in netbird-ui_${latest}_darwin_{arm64,amd64}_signed.zip netbird_${latest}_darwin_{arm64,amd64}.tar.gz; do # Release assets can show up a while after the tag. Try again on the next run. if ! curl -fsSL -o asset "$base/$asset"; then echo "$asset is not published yet" exit 0 fi sha[$asset]=$(sha256sum asset | cut -d' ' -f1) rm -f asset done sed -i -E \ -e "s/^ version \"[^\"]+\"$/ version \"$latest\"/" \ -e "s/(arm: +\")[0-9a-f]{64}/\1${sha[netbird-ui_${latest}_darwin_arm64_signed.zip]}/" \ -e "s/(intel: \")[0-9a-f]{64}/\1${sha[netbird-ui_${latest}_darwin_amd64_signed.zip]}/" \ "$cask" # The formula has literal URLs, each followed by its sha256 line. formula=Formula/netbird.rb sed -i -E "s/${current//./\\.}/$latest/g" "$formula" for arch in arm64 amd64; do asset="netbird_${latest}_darwin_${arch}.tar.gz" sed -i -E "/\/${asset//./\\.}\"/{n;s/[0-9a-f]{64}/${sha[$asset]}/}" "$formula" done git diff git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git commit -am "chore: bump netbird to $latest" git push