Release 0.4.14 #25
This file contains hidden or 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: Auto Version Bump | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check if PR was merged | |
| id: check | |
| run: | | |
| if [ "${{ github.event.pull_request.merged }}" = "true" ]; then | |
| echo "merged=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "merged=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout main branch | |
| if: steps.check.outputs.merged == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get current version | |
| if: steps.check.outputs.merged == 'true' | |
| id: current_version | |
| run: | | |
| LINE=$(grep "^version:" pubspec.yaml | sed 's/^version:[[:space:]]*//') | |
| # Drop +build, then any -prerelease (e.g. 0.4.11-b → 0.4.11). | |
| CORE=$(echo "$LINE" | sed 's/+.*//; s/-.*//') | |
| if [[ "$LINE" == *'+'* ]]; then | |
| BUILD="${LINE##*+}" | |
| else | |
| BUILD="" | |
| fi | |
| # Guard against non-numeric build leftovers. | |
| if ! [[ "$BUILD" =~ ^[0-9]+$ ]]; then | |
| BUILD="" | |
| fi | |
| echo "current_version=$CORE" >> "$GITHUB_OUTPUT" | |
| echo "current_build=$BUILD" >> "$GITHUB_OUTPUT" | |
| - name: Bump patch version | |
| if: steps.check.outputs.merged == 'true' | |
| id: bump | |
| run: | | |
| CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" | |
| CURRENT_BUILD="${{ steps.current_version.outputs.current_build }}" | |
| MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1) | |
| MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2) | |
| PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3) | |
| if ! [[ "$MAJOR$MINOR$PATCH" =~ ^[0-9]+$ ]]; then | |
| echo "Invalid core version: $CURRENT_VERSION" >&2 | |
| exit 1 | |
| fi | |
| NEW_PATCH=$((PATCH + 1)) | |
| NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" | |
| if [ -z "$CURRENT_BUILD" ]; then | |
| NEW_BUILD=1 | |
| else | |
| NEW_BUILD=$((CURRENT_BUILD + 1)) | |
| fi | |
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "new_build=$NEW_BUILD" >> "$GITHUB_OUTPUT" | |
| - name: Update pubspec.yaml | |
| if: steps.check.outputs.merged == 'true' | |
| run: | | |
| NEW_VERSION="${{ steps.bump.outputs.new_version }}" | |
| NEW_BUILD="${{ steps.bump.outputs.new_build }}" | |
| sed -i "s/^version: .*/version: ${NEW_VERSION}+${NEW_BUILD}/" pubspec.yaml | |
| grep "^version:" pubspec.yaml | |
| - name: Sync AUR PKGBUILD pkgver with pubspec | |
| if: steps.check.outputs.merged == 'true' | |
| run: | | |
| NEW_VERSION="${{ steps.bump.outputs.new_version }}" | |
| sed -i "s/^pkgver=.*/pkgver=${NEW_VERSION}/" packaging/linux/aur/PKGBUILD | |
| sed -i "s/^pkgrel=.*/pkgrel=1/" packaging/linux/aur/PKGBUILD | |
| sed -i "s/^sha256sums=.*/sha256sums=('SKIP' 'SKIP' 'SKIP')/" packaging/linux/aur/PKGBUILD | |
| grep ^pkgver packaging/linux/aur/PKGBUILD | |
| - name: Commit version bump | |
| if: steps.check.outputs.merged == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add pubspec.yaml packaging/linux/aur/PKGBUILD | |
| git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}+${{ steps.bump.outputs.new_build }}" | |
| git push origin main |