feat: add GitHub authentication and dotfiles sync functionality (#51) #1
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
| --- | |
| # SPDX-License-Identifier: MIT | |
| # | |
| # Copyright (c) 2025 Niladri Das | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all | |
| # copies or substantial portions of the Software. | |
| name: Version Bump | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Type of version bump' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| bump: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - uses: dart-lang/setup-dart@v1 | |
| - name: install dependencies | |
| run: dart pub get | |
| - name: Determine bump type | |
| id: bump | |
| run: | | |
| # shellcheck disable=SC2086 | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "bump_type=${{ inputs.bump_type }}" >> $GITHUB_OUTPUT | |
| else | |
| TYPE="" | |
| RANGE="${{ github.event.before }}..${{ github.event.after }}" | |
| for commit in $(git rev-list "$RANGE" 2>/dev/null || echo ""); do | |
| COMMIT_MSG="$(git log --format=%B -n 1 "$commit")" | |
| FIRST_LINE="$(head -1 <<< "$COMMIT_MSG")" | |
| BODY="$(tail -n +2 <<< "$COMMIT_MSG")" | |
| if grep -q '^feat' <<< "$FIRST_LINE"; then | |
| TYPE="minor" | |
| elif grep -q '^fix' <<< "$FIRST_LINE"; then | |
| TYPE="patch" | |
| fi | |
| if grep -q 'BREAKING CHANGE' <<< "$BODY"; then | |
| TYPE="major" | |
| fi | |
| if [ "$TYPE" != "" ]; then | |
| break | |
| fi | |
| done | |
| echo "bump_type=\"$TYPE\"" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: bump version | |
| if: steps.bump.outputs.bump_type != '' | |
| run: dart run version_bump.dart ${{ steps.bump.outputs.bump_type }} | |
| - name: Create PR | |
| if: steps.bump.outputs.bump_type != '' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add VERSION pubspec.yaml | |
| VERSION=$(cat VERSION) | |
| BRANCH="version-bump-$VERSION" | |
| git checkout -b "$BRANCH" | |
| git commit -m "chore: bump version to $VERSION" | |
| git push origin "$BRANCH" --force | |
| if ! gh pr list --head "$BRANCH" --state open | grep -q .; then | |
| gh pr create \ | |
| --title "chore: bump version to $VERSION at $(date)" \ | |
| --body "Automated version bump to $VERSION at $(date)" \ | |
| --head "$BRANCH" \ | |
| --base main | |
| fi |