Skip to content

prerelease a pull request #19

prerelease a pull request

prerelease a pull request #19

---
name: prerelease a pull request
on:
workflow_dispatch:
inputs:
tag:
description: "tag"
required: true
pr:
description: "pr number"
required: true
permissions:
contents: write
jobs:
release:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: gh pr checkout ${{github.event.inputs.pr}}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
permissions: >-
{
"contents": "write"
}
repositories: >-
[
"${{github.event.repository.name}}"
]
- run: gh auth setup-git
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
# https://gitpro.ttaallkk.topmunity/t/github-actions-bot-email-address/17204/5
- run: git config user.name "github-actions[bot]"
- run: git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: |
git ls-files | grep -E "/action\.yaml$" |
xargs -n 1 sed -i "s|- uses: suzuki-shunsuke/tfaction/\(.*\)@main|- uses: suzuki-shunsuke/tfaction/\1@${{github.event.inputs.tag}}|"
- run: git checkout -b "release/${{github.event.inputs.tag}}"
- run: |
git ls-files | grep -E "/action\.yaml$" | xargs git add
- run: |
git commit -m "chore: release ${{github.event.inputs.tag}}
base revision: $GITHUB_SHA"
- run: git tag "${{github.event.inputs.tag}}"
- run: git push origin "${{github.event.inputs.tag}}"
- run: git checkout main
- run: |
note_template='[Issues](https://github.com/suzuki-shunsuke/tfaction/issues?q=is%3Aissue+is%3Aclosed+milestone%3A${{github.event.inputs.tag}}) | [Pull Requests](https://github.com/suzuki-shunsuke/tfaction/pulls?q=is%3Apr+is%3Aclosed+milestone%3A${{github.event.inputs.tag}}) | https://github.com/suzuki-shunsuke/tfaction/compare/${{github.event.inputs.tag}}...${{github.event.inputs.tag}} | [Base revision](https://github.com/suzuki-shunsuke/tfaction/tree/BASE_REVISION)'
gh release create "${{github.event.inputs.tag}}" -p --title "${{github.event.inputs.tag}}" -n "${note_template//BASE_REVISION/$GITHUB_SHA}"
env:
GITHUB_TOKEN: ${{ github.token }}