chore(release): prepare for v0.9.1 #47
Workflow file for this run
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: Prepare Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
prepare-release: | |
runs-on: ubuntu-latest | |
if: startsWith(github.head_ref, 'release-v') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract version from pubspec.yaml | |
run: | | |
VERSION_FULL=$(grep '^version:' pubspec.yaml | sed 's/version: //') | |
VERSION_NAME=$(echo $VERSION_FULL | cut -d '+' -f 1) | |
VERSION_NUMBER=$(echo $VERSION_FULL | cut -d '+' -f 2) | |
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | |
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV | |
echo "Version Name: $VERSION_NAME" | |
echo "Version Number: $VERSION_NUMBER" | |
- name: Generate changelog | |
uses: orhun/git-cliff-action@v4 | |
with: | |
config: cliff.toml | |
args: --tag $VERSION_NAME a547cf240dd36443a9a00eb38c0ecc6e8acfd963.. | |
env: | |
OUTPUT: CHANGELOG.md | |
GITHUB_REPO: ${{ github.repository }} | |
- name: Commit Changelog | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout ${{ github.head_ref }} | |
git add CHANGELOG.md | |
git commit -m "Update CHANGELOG for version $VERSION_NAME" | |
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref }} | |
- name: Update PR Title | |
if: github.event_name == 'pull_request' | |
run: | | |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | |
NEW_TITLE="chore(release): prepare for v${VERSION_NAME}" | |
curl -X PATCH -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER \ | |
-d "{\"title\":\"$NEW_TITLE\"}" |