|
| 1 | +name: Bump action runner version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + plan: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + |
| 10 | +jobs: |
| 11 | + main: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + env: |
| 14 | + PLAN: ${{ inputs.plan }} |
| 15 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 16 | + steps: |
| 17 | + - name: Plan details |
| 18 | + run: | |
| 19 | + echo "Plan details: $PLAN" |
| 20 | +
|
| 21 | + - name: Update release title and body |
| 22 | + run: | |
| 23 | + RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag') |
| 24 | + ANNOUNCEMENT_TITLE=$(echo ${PLAN} | jq -r '.announcement_title') |
| 25 | + ANNOUNCEMENT_BODY=$(echo ${PLAN} | jq -r '.announcement_github_body') |
| 26 | + REPO_OWNER=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.owner') |
| 27 | + REPO_NAME=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.repo') |
| 28 | +
|
| 29 | + echo "Updating release ${RELEASE_TAG} with title and body from dist plan" |
| 30 | +
|
| 31 | + # Write body to file to avoid quoting issues |
| 32 | + echo "$ANNOUNCEMENT_BODY" > /tmp/release-notes.txt |
| 33 | +
|
| 34 | + # Update the release with title and body |
| 35 | + gh release edit "${RELEASE_TAG}" \ |
| 36 | + -R "${REPO_OWNER}/${REPO_NAME}" \ |
| 37 | + --title "${ANNOUNCEMENT_TITLE}" \ |
| 38 | + --notes-file /tmp/release-notes.txt |
| 39 | +
|
| 40 | + echo "Release metadata updated successfully" |
| 41 | +
|
| 42 | + - name: Check if runner was released |
| 43 | + id: check_runner |
| 44 | + run: | |
| 45 | + IS_PRE_RELEASE=$(echo ${PLAN} | jq '.announcement_is_prerelease') |
| 46 | + NEW_VERSION=$(echo ${PLAN} | jq -r '.releases[] | select(.app_name == "codspeed-runner") | .app_version') |
| 47 | + RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag') |
| 48 | +
|
| 49 | + echo "is_pre_release=${IS_PRE_RELEASE}" >> "$GITHUB_OUTPUT" |
| 50 | + echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" |
| 51 | + echo "release_tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT" |
| 52 | +
|
| 53 | + if [ "${IS_PRE_RELEASE}" == "true" ]; then |
| 54 | + echo "runner_released=false" >> "$GITHUB_OUTPUT" |
| 55 | + echo "Pre-release detected, will not mark as latest or bump action" |
| 56 | + elif [ -z "${NEW_VERSION}" ] || [ "${NEW_VERSION}" == "null" ]; then |
| 57 | + echo "runner_released=false" >> "$GITHUB_OUTPUT" |
| 58 | + echo "No codspeed-runner release found in plan" |
| 59 | + else |
| 60 | + echo "runner_released=true" >> "$GITHUB_OUTPUT" |
| 61 | + echo "Runner version ${NEW_VERSION} was released" |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Mark release as latest |
| 65 | + if: steps.check_runner.outputs.runner_released == 'true' |
| 66 | + run: | |
| 67 | + RELEASE_TAG="${{ steps.check_runner.outputs.release_tag }}" |
| 68 | + REPO_OWNER=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.owner') |
| 69 | + REPO_NAME=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.repo') |
| 70 | + echo "Marking release ${RELEASE_TAG} as latest" |
| 71 | + gh release edit "${RELEASE_TAG}" -R "${REPO_OWNER}/${REPO_NAME}" --latest |
| 72 | +
|
| 73 | + - name: Trigger action runner version bump workflow |
| 74 | + if: steps.check_runner.outputs.runner_released == 'true' |
| 75 | + env: |
| 76 | + GH_TOKEN: ${{ secrets.PAT_CODSPEED_ACTION }} |
| 77 | + run: | |
| 78 | + NEW_VERSION="${{ steps.check_runner.outputs.new_version }}" |
| 79 | + echo "Triggering action runner version bump for version ${NEW_VERSION}" |
| 80 | + # Trigger the bump-runner-version workflow in the CodSpeedHQ/actions repository |
| 81 | + gh workflow run bump-runner-version.yml -R CodSpeedHQ/action -f version=${NEW_VERSION} |
0 commit comments