Skip to content

Commit

Permalink
ci: auto increase build number on pull requests (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
xfqwdsj authored Jan 27, 2024
1 parent 8f4c263 commit 958d812
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/increase-build-number.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Increase build number on pull request

on:
pull_request:
branches:
- main

permissions:
contents: write

jobs:
increase-build-number:
if: !startsWith(github.event.pull_request.title, 'ci:')
name: Increase build number
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Increase build number
id: increase-build-number
run: |
buildNumber=$(grep buildNumber= build-number.properties | cut -d'=' -f2)
buildNumber=$((buildNumber+1))
sed -i "s/buildNumber=.*/buildNumber=$buildNumber/" build-number.properties
echo "buildNumber=$buildNumber" >> $GITHUB_OUTPUT
- name: Commit and push changes
run: |
git config user.name github-actions
git add build-number.properties
git commit -m "chore: increase build number to ${{ steps.increase-build-number.outputs.buildNumber }}"
git push

0 comments on commit 958d812

Please sign in to comment.