Feat: Favorite function #25
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: Update version | |
on: | |
pull_request: | |
types: [closed] | |
jobs: | |
update_version: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Update version | |
run: | | |
# Extract the current version number | |
version=$(grep 'version:' pubspec.yaml | awk '{print $2}' | awk -F "+" '{print $1}') | |
build=$(grep 'version:' pubspec.yaml | awk '{print $2}' | awk -F "+" '{print $2}') | |
# Increment the version number | |
new_version="${version%.*}.$((${version##*.}+1))" | |
# Replace the version number in the pubspec.yaml file | |
sed -i "s/version: $version+$build/version: $new_version+$build/g" pubspec.yaml | |
- name: Create new branch and commit changes | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
branch_name="version-update-$(date +'%Y%m%d%H%M%S')" | |
git checkout -b $branch_name | |
git commit -am "Increment version number" | |
git push origin $branch_name | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
title: "Increment version number" | |
body: "This PR increments the version number in `pubspec.yaml`." | |
branch: ${{ github.ref }} |