From f220bcc5d6d167d6aef3c0118acc2096f4a67101 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 09:55:17 +0100 Subject: [PATCH 1/6] ci: renterd.yml --- .github/workflows/renterd.yml | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/renterd.yml diff --git a/.github/workflows/renterd.yml b/.github/workflows/renterd.yml new file mode 100644 index 0000000..14ccb03 --- /dev/null +++ b/.github/workflows/renterd.yml @@ -0,0 +1,45 @@ +name: Update Renterd Formula + +on: + # Run hourly + schedule: + - cron: '0 * * * *' + # Enable manual trigger + workflow_dispatch: + +jobs: + update-formula: + runs-on: ubuntu-latest + + steps: + - name: Checkout respository + uses: actions/checkout@v3 + + - name: Check for new renterd tag in SiaFoundation/renterd + id: check-tag + env: + GH_TOKEN: ${{ github.token }} + run: | + # Fetch tags with pagination + TAGS_JSON=$(gh api --paginate repos/SiaFoundation/web/tags) + + # Extract tags that start with "renterd/", sort them in version order, and pick the highest version + LATEST_RENTERD_GO_TAG=$(echo "$TAGS_JSON" | jq -r '.[] | select(.name | startswith("v")).name' | sort -Vr | head -n 1) + LATEST_RENTERD_VERSION=$(echo "$LATEST_RENTERD_GO_TAG") + + echo "Latest renterd tag is $LATEST_RENTERD_GO_TAG" + echo "GO_TAG=$LATEST_RENTERD_GO_TAG" >> $GITHUB_ENV + echo "VERSION=$LATEST_RENTERD_VERSION" >> $GITHUB_ENV + + - name: Update Homebrew Formula + run: sed -i '' 's/:tag => "[^"]*"/:tag => "${{ env.GO_TAG }}"/' ./Formula/renterd.rb + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5.0.2 + with: + token: ${{ secrets.HOMEBREW_CREATE_PR }} + commit-message: 'renterd: ${{ env.GO_TAG }}' + title: 'renterd: ${{ env.GO_TAG }}' + body: 'This is an automated PR to update the formula of renterd' + branch: renterd/update + base: master From b7df713dae21957a6b8446700b47245d2366e243 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 10:09:25 +0100 Subject: [PATCH 2/6] add debug trigger --- .github/workflows/renterd.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/renterd.yml b/.github/workflows/renterd.yml index 14ccb03..5edefac 100644 --- a/.github/workflows/renterd.yml +++ b/.github/workflows/renterd.yml @@ -1,6 +1,11 @@ name: Update Renterd Formula on: + push: + branches: + - master + tags: + - 'vDEBUG' # Run hourly schedule: - cron: '0 * * * *' From f6458c894ceb4ae2b9d63a02c9cf8081dd78b801 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 10:13:22 +0100 Subject: [PATCH 3/6] fix sed --- .github/workflows/renterd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/renterd.yml b/.github/workflows/renterd.yml index 5edefac..5214802 100644 --- a/.github/workflows/renterd.yml +++ b/.github/workflows/renterd.yml @@ -26,7 +26,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | # Fetch tags with pagination - TAGS_JSON=$(gh api --paginate repos/SiaFoundation/web/tags) + TAGS_JSON=$(gh api --paginate repos/SiaFoundation/renterd/tags) # Extract tags that start with "renterd/", sort them in version order, and pick the highest version LATEST_RENTERD_GO_TAG=$(echo "$TAGS_JSON" | jq -r '.[] | select(.name | startswith("v")).name' | sort -Vr | head -n 1) @@ -37,7 +37,7 @@ jobs: echo "VERSION=$LATEST_RENTERD_VERSION" >> $GITHUB_ENV - name: Update Homebrew Formula - run: sed -i '' 's/:tag => "[^"]*"/:tag => "${{ env.GO_TAG }}"/' ./Formula/renterd.rb + run: sed -i 's/:tag => "[^"]*"/:tag => "${{ env.GO_TAG }}"/' ./Formula/renterd.rb - name: Create Pull Request uses: peter-evans/create-pull-request@v5.0.2 From 8c578ba0bced9ec65255df56023eb225d461a35e Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 10:28:11 +0100 Subject: [PATCH 4/6] ci: use github token --- .github/workflows/renterd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/renterd.yml b/.github/workflows/renterd.yml index 5214802..2c7a29e 100644 --- a/.github/workflows/renterd.yml +++ b/.github/workflows/renterd.yml @@ -42,7 +42,7 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v5.0.2 with: - token: ${{ secrets.HOMEBREW_CREATE_PR }} + token: ${{ secrets.GITHUB_TOKEN }} commit-message: 'renterd: ${{ env.GO_TAG }}' title: 'renterd: ${{ env.GO_TAG }}' body: 'This is an automated PR to update the formula of renterd' From dcaef61d2b4ba3859a6afa2413f66fdb0350d187 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 10:42:08 +0100 Subject: [PATCH 5/6] ci: use matrix --- .github/workflows/formula-update.yml | 47 ++++++++++++++++++++++++++ .github/workflows/renterd.yml | 50 ---------------------------- 2 files changed, 47 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/formula-update.yml delete mode 100644 .github/workflows/renterd.yml diff --git a/.github/workflows/formula-update.yml b/.github/workflows/formula-update.yml new file mode 100644 index 0000000..0dea1ab --- /dev/null +++ b/.github/workflows/formula-update.yml @@ -0,0 +1,47 @@ +name: Update Homebrew Formulas + +on: + # Run hourly + schedule: + - cron: '0 * * * *' + # Enable manual trigger + workflow_dispatch: + +jobs: + update-formula: + runs-on: ubuntu-latest + strategy: + matrix: + formula: ["renterd", "hostd"] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check for new tag in ${{ matrix.formula }} repository + id: check-tag + env: + GH_TOKEN: ${{ github.token }} + run: | + # Fetch tags with pagination + TAGS_JSON=$(gh api --paginate repos/SiaFoundation/${{ matrix.formula }}/tags) + + # Extract tags, sort them in version order, and pick the highest version + LATEST_TAG=$(echo "$TAGS_JSON" | jq -r '.[] | select(.name | startswith("v")).name' | sort -Vr | head -n 1) + + echo "Latest tag for ${{ matrix.formula }} is $LATEST_TAG" + echo "GO_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "VERSION=$LATEST_TAG" >> $GITHUB_ENV + + - name: Update Homebrew Formula for ${{ matrix.formula }} + run: sed -i 's/:tag => "[^"]*"/:tag => "${{ env.GO_TAG }}"/' ./Formula/${{ matrix.formula }}.rb + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5.0.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: '${{ matrix.formula }}: ${{ env.GO_TAG }}' + title: '${{ matrix.formula }}: ${{ env.GO_TAG }}' + body: 'This is an automated PR to update the ${{ matrix.formula }} formula' + branch: ${{ matrix.formula }}/update + base: master diff --git a/.github/workflows/renterd.yml b/.github/workflows/renterd.yml deleted file mode 100644 index 2c7a29e..0000000 --- a/.github/workflows/renterd.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Update Renterd Formula - -on: - push: - branches: - - master - tags: - - 'vDEBUG' - # Run hourly - schedule: - - cron: '0 * * * *' - # Enable manual trigger - workflow_dispatch: - -jobs: - update-formula: - runs-on: ubuntu-latest - - steps: - - name: Checkout respository - uses: actions/checkout@v3 - - - name: Check for new renterd tag in SiaFoundation/renterd - id: check-tag - env: - GH_TOKEN: ${{ github.token }} - run: | - # Fetch tags with pagination - TAGS_JSON=$(gh api --paginate repos/SiaFoundation/renterd/tags) - - # Extract tags that start with "renterd/", sort them in version order, and pick the highest version - LATEST_RENTERD_GO_TAG=$(echo "$TAGS_JSON" | jq -r '.[] | select(.name | startswith("v")).name' | sort -Vr | head -n 1) - LATEST_RENTERD_VERSION=$(echo "$LATEST_RENTERD_GO_TAG") - - echo "Latest renterd tag is $LATEST_RENTERD_GO_TAG" - echo "GO_TAG=$LATEST_RENTERD_GO_TAG" >> $GITHUB_ENV - echo "VERSION=$LATEST_RENTERD_VERSION" >> $GITHUB_ENV - - - name: Update Homebrew Formula - run: sed -i 's/:tag => "[^"]*"/:tag => "${{ env.GO_TAG }}"/' ./Formula/renterd.rb - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5.0.2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'renterd: ${{ env.GO_TAG }}' - title: 'renterd: ${{ env.GO_TAG }}' - body: 'This is an automated PR to update the formula of renterd' - branch: renterd/update - base: master From 943b07805eba7b6c8c4556d591e6b9d0df5b7892 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 10:45:03 +0100 Subject: [PATCH 6/6] ci: remove redundant line --- .github/workflows/formula-update.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/formula-update.yml b/.github/workflows/formula-update.yml index 0dea1ab..f20ada0 100644 --- a/.github/workflows/formula-update.yml +++ b/.github/workflows/formula-update.yml @@ -31,7 +31,6 @@ jobs: echo "Latest tag for ${{ matrix.formula }} is $LATEST_TAG" echo "GO_TAG=$LATEST_TAG" >> $GITHUB_ENV - echo "VERSION=$LATEST_TAG" >> $GITHUB_ENV - name: Update Homebrew Formula for ${{ matrix.formula }} run: sed -i 's/:tag => "[^"]*"/:tag => "${{ env.GO_TAG }}"/' ./Formula/${{ matrix.formula }}.rb