Version Bump #723
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: Version Bump | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
| SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }} | |
| on: | |
| workflow_run: | |
| workflows: | |
| - BUG Server Tests | |
| - Module Container Tests | |
| - BUG Client Tests | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: version-bump-${{ github.event.workflow_run.head_sha || github.sha }} | |
| cancel-in-progress: true | |
| permissions: | |
| actions: read | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| slack-start: | |
| name: Slack start message | |
| runs-on: ubuntu-latest | |
| outputs: | |
| ts: ${{ steps.slack-start.outputs.ts }} | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@v6 | |
| - name: send slack start message | |
| id: slack-start | |
| uses: ./.github/actions/slack-run-start | |
| with: | |
| message_prefix: Workflow running | |
| verify-tests: | |
| name: Verify required tests passed | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: check required workflow results | |
| id: required-tests | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const requiredWorkflows = [ | |
| "test-bug-server.yml", | |
| "test-module-container.yml", | |
| "test-bug-client.yml", | |
| ]; | |
| const headSha = context.payload.workflow_run?.head_sha ?? context.sha; | |
| const branch = context.payload.workflow_run?.head_branch ?? context.ref.replace("refs/heads/", ""); | |
| for (const workflowId of requiredWorkflows) { | |
| const runs = await github.paginate(github.rest.actions.listWorkflowRuns, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: workflowId, | |
| branch, | |
| per_page: 100, | |
| }); | |
| const shaRuns = runs.filter((run) => run.head_sha === headSha); | |
| if (shaRuns.length === 0) { | |
| core.info(`${workflowId} did not run for ${headSha}; treating it as not required for this commit.`); | |
| continue; | |
| } | |
| const successfulRun = shaRuns.find((run) => ( | |
| run.status === "completed" | |
| && run.conclusion === "success" | |
| )); | |
| if (!successfulRun) { | |
| core.info(`${workflowId} has not completed successfully for ${headSha}.`); | |
| core.setOutput("tests_passed", "false"); | |
| return; | |
| } | |
| } | |
| core.setOutput("tests_passed", "true"); | |
| - name: fail when required tests are not ready | |
| if: steps.required-tests.outputs.tests_passed != 'true' | |
| run: | | |
| echo "One or more relevant test workflows have not completed successfully for this SHA." | |
| exit 1 | |
| version: | |
| needs: verify-tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: setup node | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: install dependencies | |
| run: npm ci | |
| - name: update module changelogs | |
| run: node .github/scripts/updateModules.js | |
| - name: commit changelog/module changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add src/modules | |
| git diff --cached --quiet || git commit -m "ci: update module changelogs and bump versions" | |
| git push | |
| - name: update app changelogs | |
| run: node .github/scripts/updateApp.js | |
| - name: commit changelog/app changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add CHANGELOG.md package.json src/client/package.json | |
| git diff --cached --quiet || git commit -m "ci: update app changelog and bump versions" | |
| git push | |
| slack-finish: | |
| name: Slack final status | |
| if: ${{ always() && needs.slack-start.outputs.ts != '' }} | |
| needs: | |
| - slack-start | |
| - verify-tests | |
| - version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@v6 | |
| - name: set end timestamp | |
| id: end-time | |
| run: echo "value=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | |
| - name: determine workflow status | |
| id: workflow-status | |
| run: | | |
| workflow_status="success" | |
| # If the required test gate fails, delete the start notification. | |
| if [[ "${{ needs.verify-tests.result }}" == "failure" || "${{ needs.verify-tests.result }}" == "cancelled" ]]; then | |
| workflow_status="skipped" | |
| elif [[ "${{ needs.version.result }}" == "failure" || "${{ needs.version.result }}" == "cancelled" ]]; then | |
| workflow_status="failure" | |
| fi | |
| echo "status=$workflow_status" >> "$GITHUB_OUTPUT" | |
| - name: update slack message | |
| uses: ./.github/actions/slack-run-finish | |
| with: | |
| ts: ${{ needs.slack-start.outputs.ts }} | |
| status: ${{ steps.workflow-status.outputs.status }} | |
| message_prefix: Workflow |