From dcaef61d2b4ba3859a6afa2413f66fdb0350d187 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 22 Jan 2024 10:42:08 +0100 Subject: [PATCH] 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