From 6cb884b2f87a60ce70eec9cdd82764a0eda51fc3 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 11 Jun 2026 10:20:18 +0200 Subject: [PATCH] ci: add beta branch --- .github/actions/update-ha-config/action.yml | 47 +++++++++++++++++++++ .github/workflows/release.yml | 42 +++++++++--------- 2 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 .github/actions/update-ha-config/action.yml diff --git a/.github/actions/update-ha-config/action.yml b/.github/actions/update-ha-config/action.yml new file mode 100644 index 0000000..ca7e23b --- /dev/null +++ b/.github/actions/update-ha-config/action.yml @@ -0,0 +1,47 @@ +name: 'Update HA Config' +description: 'Update psacc-ha config.json with new version' +inputs: + gh_token: + description: 'GitHub PAT token' + required: true + version: + description: 'Version to set' + required: true + branch: + description: 'Branch to update (main or beta)' + required: true + default: 'main' + message: + description: 'Commit message' + required: true +runs: + using: "composite" + steps: + - name: Update psacc-ha config + env: + GH_TOKEN: ${{ inputs.gh_token }} + VERSION: ${{ inputs.version }} + BRANCH: ${{ inputs.branch }} + MESSAGE: ${{ inputs.message }} + run: | + echo "Updating flobz/psacc-ha config.json to $VERSION on branch $BRANCH" + + # Build API URL with ref parameter if beta + API_URL="repos/flobz/psacc-ha/contents/psacc-ha/config.json" + [[ "$BRANCH" == "beta" ]] && API_URL="${API_URL}?ref=beta" + + # Get current content and SHA + RESPONSE=$(gh api $API_URL) + FILE_SHA=$(echo "$RESPONSE" | jq -r '.sha') + CURRENT_CONTENT=$(echo "$RESPONSE" | jq -r '.content' | base64 -d) + + # Replace version + NEW_CONTENT=$(echo "$CURRENT_CONTENT" | sed "s/\"version\": \"v[^\"]*\"/\"version\": \"$VERSION\"/") + + # Update file + gh api $API_URL \ + -X PUT \ + -f message="$MESSAGE" \ + -f content="$(echo "$NEW_CONTENT" | base64 -w 0)" \ + -f sha="$FILE_SHA" + shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c731ef8..d1bf33d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,26 +84,24 @@ jobs: needs: push_to_registry name: Update psacc-ha version runs-on: ubuntu-latest - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'b') steps: - - name: Update psacc-ha version - env: - GH_TOKEN: ${{ secrets.GH_PAT }} - VERSION: ${{ github.ref_name }} - run: | - echo "Updating flobz/psacc-ha config.json to $VERSION" - - # Get current content and SHA - RESPONSE=$(gh api repos/flobz/psacc-ha/contents/psacc-ha/config.json) - FILE_SHA=$(echo "$RESPONSE" | jq -r '.sha') - CURRENT_CONTENT=$(echo "$RESPONSE" | jq -r '.content' | base64 -d) - - # Replace version - NEW_CONTENT=$(echo "$CURRENT_CONTENT" | sed "s/\"version\": \"v[^\"]*\"/\"version\": \"$VERSION\"/") - - # Update file - gh api repos/flobz/psacc-ha/contents/psacc-ha/config.json \ - -X PUT \ - -f message="chore: bump version to $VERSION" \ - -f content="$(echo "$NEW_CONTENT" | base64 -w 0)" \ - -f sha="$FILE_SHA" + - uses: ./.github/actions/update-ha-config + with: + gh_token: ${{ secrets.GH_PAT }} + version: ${{ github.ref_name }} + branch: 'main' + message: "chore: bump version to ${{ github.ref_name }}" + + update_ha_config_beta: + needs: push_to_registry + name: Update psacc-ha beta version + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'b') + steps: + - uses: ./.github/actions/update-ha-config + with: + gh_token: ${{ secrets.GH_PAT }} + version: ${{ github.ref_name }} + branch: 'beta' + message: "chore: bump beta version to ${{ github.ref_name }}"