Skip to content

Release

Release #41

Workflow file for this run

---
name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'tag'
required: true
ref:
description: 'released ref (branch, tag or SHA). By default, the default branch is used'
required: false
default: ''
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{github.event.inputs.ref}}
- run: echo "BASE_REVISION=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- run: gh auth setup-git
env:
GITHUB_TOKEN: ${{ github.token }}
# https://github.community/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: $BASE_REVISION"
- run: git tag "${{github.event.inputs.tag}}"
- run: git push origin "${{github.event.inputs.tag}}"
- 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/$BASE_REVISION}"
env:
GITHUB_TOKEN: ${{ github.token }}