Bump sorbet from 0.5.11608 to 0.5.11609 (#558) #338
This file contains 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: Create/Update Release PR | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
level: | |
default: minor | |
required: false | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
description: 'bump to [major|minor|patch]' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: heromo/pronto-action | |
jobs: | |
prepare: | |
name: Prepare Versions and Release Note | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
outputs: | |
exist-release-pr: ${{ steps.release-pr.outputs.result }} | |
release-pr: ${{ steps.release-pr.outputs.pr }} | |
release-note: ${{ steps.release-note.outputs.release-note }} | |
latest-version: ${{ steps.versions.outputs.latest-version }} | |
next-version: ${{ steps.versions.outputs.next-version }} | |
timeout-minutes: 60 | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Fetch Latest & Next Release Version | |
uses: actions/github-script@v7 | |
id: versions | |
with: | |
script: | | |
const script = require('./.github/wf-scripts/latest-version.js'); | |
let level = 'minor'; | |
if ('${{ inputs.level }}' != '') level = '${{ inputs.level }}'; | |
return await script({github, context, core, level}); | |
- name: Generate Release Note | |
uses: actions/github-script@v7 | |
id: release-note | |
with: | |
script: | | |
const script = require('./.github/wf-scripts/release-note.js'); | |
const latestVersion = '${{ steps.versions.outputs.latest-version }}'; | |
const nextVersion = '${{ steps.versions.outputs.next-version }}'; | |
await script({github, context, core, latestVersion, nextVersion}); | |
- name: Fetch Release PR | |
uses: actions/github-script@v7 | |
id: release-pr | |
with: | |
script: | | |
const nextVersion = '${{ steps.versions.outputs.next-version }}'; | |
const pulls = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
head: `heromo:release/${ nextVersion }`, | |
}); | |
const pull = pulls.data[0]; | |
core.setOutput('pr', pull); | |
return !!pull | |
- name: Create Issue on Failure | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const create = await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: "Failed to prepare create/update release pr", | |
body: `Automation has failed! Failed to create/update release pr for '${{ steps.versions.outputs.next-version }}'\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, | |
assignees: [ | |
'${{ github.repository_owner }}' | |
] | |
}) | |
create-release-pr: | |
name: Create Release Pull Request | |
needs: prepare | |
if: needs.prepare.outputs.exist-release-pr == 'false' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
timeout-minutes: 60 | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Git config | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b release/${{ needs.prepare.outputs.next-version }} | |
- name: Modify files | |
run: | | |
yq '.runs.image = "docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.next-version }}"' -i action.yaml | |
sed -i -r 's/pronto-action@v[0-9]+\.[0-9]+\.[0-9]+/pronto-action@${{ needs.prepare.outputs.next-version }}/' README.md | |
git add action.yaml README.md | |
- name: check diff | |
shell: bash | |
id: changes | |
run: | | |
echo "count=$(git diff --staged --name-only . |wc -l)" >> $GITHUB_OUTPUT | |
- name: Commit and Push if changed | |
if: steps.changes.outputs.count > 0 | |
run: | | |
git commit -m 'bumpup image version' | |
git push origin release/${{ needs.prepare.outputs.next-version }} | |
- name: Create PR | |
if: steps.changes.outputs.count > 0 | |
uses: actions/github-script@v7 | |
id: create-pr | |
with: | |
script: | | |
const releaseNote = ${{ needs.prepare.outputs.release-note }}; | |
const { data: pull } = await github.rest.pulls.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
head: 'release/${{ needs.prepare.outputs.next-version }}', | |
base: 'main', | |
title: 'Release ${{ needs.prepare.outputs.next-version }}', | |
body: releaseNote.data.body | |
}); | |
core.setOutput('created-pr', pull); | |
github.rest.issues.addAssignees({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pull.number, | |
assignees: [context.repo.owner], | |
}); | |
github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pull.number, | |
labels: ['release'], | |
}); | |
- name: Create Issue on Failure | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const create = await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: "Failed to create release pr", | |
body: `Automation has failed! Failed to create release pr for '${{ needs.prepare.outputs.next-version }}'\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, | |
assignees: [ | |
'${{ github.repository_owner }}' | |
] | |
}) | |
update-release-pr: | |
name: Update Release Pull Request | |
needs: prepare | |
if: needs.prepare.outputs.exist-release-pr == 'true' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
timeout-minutes: 60 | |
steps: | |
- name: Update PR | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const releasePull = ${{ needs.prepare.outputs.release-pr }}; | |
const releaseNote = ${{ needs.prepare.outputs.release-note }}; | |
const { data: pull } = await github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: releasePull.number, | |
body: releaseNote.data.body | |
}); | |
core.setOutput('updated-pr', pull); | |
- name: Create Issue on Failure | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const releasePull = ${{ needs.prepare.outputs.release-pr }}; | |
const create = await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: "Failed to update release pr", | |
body: `Automation has failed! Failed to update release pr '${releasePull.title}'\nMore information can be found at:\n - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, | |
assignees: [ | |
'${{ github.repository_owner }}' | |
] | |
}) | |