Automated Valkey Bundle Release #496
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Automated Valkey Bundle Release | |
| on: | |
| repository_dispatch: | |
| types: [valkey-release, json-release, bloom-release, search-release, ldap-release] | |
| schedule: | |
| - cron: '0 3 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to be released' | |
| required: true | |
| component: | |
| description: 'Valkey Bundle component to be released' | |
| required: true | |
| type: choice | |
| options: [valkey, json, bloom, search, ldap] | |
| permissions: | |
| actions: write | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| trigger-ci: | |
| name: Trigger CI | |
| if: (github.event_name == 'schedule' && github.repository_owner == 'valkey-io') || (github.event_name == 'workflow_dispatch' && inputs.version == 'unstable' && inputs.component == 'valkey') | |
| uses: ./.github/workflows/ci.yml | |
| with: | |
| version: unstable | |
| secrets: inherit | |
| update-files: | |
| name: Update Files and Create Pull Request | |
| if: github.event_name == 'repository_dispatch' || (github.event_name == 'workflow_dispatch' && inputs.version != 'unstable') | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: valkey-bundle-updates | |
| cancel-in-progress: false | |
| defaults: | |
| run: | |
| shell: bash | |
| working-directory: ./valkey-bundle | |
| steps: | |
| - name: Generate token | |
| id: generate-token | |
| if: github.repository_owner == 'valkey-io' | |
| uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0 | |
| with: | |
| app-id: ${{ secrets.VALKEYRIE_BOT_APP_ID }} | |
| private-key: ${{ secrets.VALKEYRIE_BOT_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: valkey-bundle | |
| - name: Checkout Valkey-Bundle | |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| with: | |
| fetch-depth: 0 | |
| path: valkey-bundle | |
| - name: Configure Git For Valkey-Bundle | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Checkout valkey-container | |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| with: | |
| repository: ${{ github.repository_owner }}/valkey-container | |
| path: valkey-container | |
| clean: false | |
| - name: Checkout valkey-release-automation | |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| with: | |
| repository: ${{ github.repository_owner }}/valkey-release-automation | |
| path: valkey-release-automation | |
| - name: Exclude valkey-container in bundle repo | |
| run: | | |
| echo "/valkey-container" >> .git/info/exclude | |
| git status --porcelain | |
| - name: Check for an existing pull request branch | |
| id: check-branch | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BRANCH_NAME="valkey-bundle-update" | |
| echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then | |
| echo "branch-exists=true" >> $GITHUB_OUTPUT | |
| echo "Checking out existing branch" | |
| git fetch origin "$BRANCH_NAME" | |
| git checkout "$BRANCH_NAME" | |
| git pull --ff-only origin "$BRANCH_NAME" | |
| else | |
| echo "branch-exists=false" >> $GITHUB_OUTPUT | |
| echo "Staying on mainline for new branch creation" | |
| fi | |
| - name: Process inputs | |
| id: process-inputs | |
| run: | | |
| if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then | |
| # From "repository_dispatch" trigger | |
| echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT | |
| echo "component=${{ github.event.client_payload.component }}" >> $GITHUB_OUTPUT | |
| else | |
| # From "workflow_dispatch" trigger | |
| echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| echo "component=${{ github.event.inputs.component }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Python | |
| uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Update versions.json | |
| id: update-versions | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| python scripts/update-versions.py versions.json \ | |
| "${{ steps.process-inputs.outputs.component }}" \ | |
| "${{ steps.process-inputs.outputs.version }}" | |
| if git diff --quiet versions.json; then | |
| echo "No Changes to Commit" | |
| echo "has-changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "has-changes=true" >> $GITHUB_OUTPUT | |
| git add versions.json | |
| git commit -m "Update versions.json for ${{ steps.process-inputs.outputs.component }} ${{ steps.process-inputs.outputs.version }}" | |
| fi | |
| - name: Update Dockerfiles | |
| if: steps.update-versions.outputs.has-changes == 'true' | |
| run: | | |
| # Fetch template helpers into bundle/ | |
| jqt='.jq-template.awk' | |
| wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk' | |
| jqf='.template-helper-functions.jq' | |
| wget -qO "$jqf" 'https://github.com/docker-library/bashbrew/raw/08c926140ad0af22de58c2a2656afda58082ba3e/scripts/template-helper-functions.jq' | |
| ./apply-templates.sh | |
| # Stage all changes from apply-templates.sh | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "No Dockerfile changes to commit" | |
| else | |
| git commit -m "Update Dockerfiles for ${{ steps.process-inputs.outputs.component }} ${{ steps.process-inputs.outputs.version }}" | |
| fi | |
| - name: Set up bashbrew | |
| uses: docker-library/bashbrew@a519e31d2ed9cb229ff38ab4488e78bfa09d7a2a # v0.1.14 | |
| - name: Generate Jobs Strategy | |
| id: generate-jobs | |
| run: | | |
| strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")" | |
| echo "strategy=$(echo "$strategy" | jq -c '.')" >> $GITHUB_OUTPUT | |
| - name: Update DockerHub description | |
| if: steps.update-versions.outputs.has-changes == 'true' | |
| run: | | |
| echo '${{ steps.generate-jobs.outputs.strategy }}' > strategy.json | |
| python scripts/update-dockerhub-description.py strategy.json dockerhub-description-template.md dockerhub-description.md | |
| rm strategy.json | |
| git add dockerhub-description.md | |
| git commit -m "Update DockerHub description for ${{ steps.process-inputs.outputs.component }} ${{ steps.process-inputs.outputs.version }}" || echo "No changes to commit" | |
| - name: Update Bundle Alias | |
| if: steps.process-inputs.outputs.component == 'valkey' && steps.update-versions.outputs.has-changes == 'true' | |
| run: | | |
| python ../valkey-release-automation/scripts/automate_alias_update.py generate-stackbrew-library.sh "${{ steps.process-inputs.outputs.version }}" | |
| git add generate-stackbrew-library.sh | |
| git commit -m "Update alias for valkey version ${{ steps.process-inputs.outputs.version }}" || echo "No changes to commit" | |
| - name: Push changes and update existing PR | |
| if: steps.check-branch.outputs.branch-exists == 'true' && steps.update-versions.outputs.has-changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.repository_owner == 'valkey-io' && steps.generate-token.outputs.token || secrets.VALKEY_BUNDLE_PAT_FOR_PR }} | |
| run: | | |
| BRANCH_NAME="${{ steps.check-branch.outputs.branch-name }}" | |
| git push origin HEAD:"$BRANCH_NAME" | |
| - name: Create Pull Request | |
| if: steps.check-branch.outputs.branch-exists == 'false' && steps.update-versions.outputs.has-changes == 'true' | |
| uses: peter-evans/create-pull-request@4e1beaa7521e8b457b572c090b25bd3db56bf1c5 # v5.0.3 | |
| with: | |
| path: valkey-bundle | |
| token: ${{ github.repository_owner == 'valkey-io' && steps.generate-token.outputs.token || secrets.VALKEY_BUNDLE_PAT_FOR_PR }} | |
| branch: ${{ steps.check-branch.outputs.branch-name }} | |
| delete-branch: false | |
| title: "Automated Updates for Valkey Bundle" | |
| body: | | |
| **Automated:** This PR contains automated updates for the valkey bundle release. | |
| Changes include: | |
| - Updated versions.json | |
| - Updated Dockerfiles | |
| - Updated DockerHub description | |
| - name: Comment on Pull Request | |
| if: steps.update-versions.outputs.has-changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.repository_owner == 'valkey-io' && steps.generate-token.outputs.token || secrets.VALKEY_BUNDLE_PAT_FOR_PR }} | |
| run: | | |
| BRANCH_NAME="${{ steps.check-branch.outputs.branch-name }}" | |
| gh pr comment "$BRANCH_NAME" --body "**Automated:** Updated ${{ steps.process-inputs.outputs.component }} to version ${{ steps.process-inputs.outputs.version }}." |