Add SpyHunt v4.0 universal installer script #5
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: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| paths-ignore: | |
| - 'VERSION' | |
| - '**.md' | |
| - '.github/**' | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: 'patch' | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| - name: Determine bump type | |
| id: bump_type | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "type=${{ inputs.bump_type }}" >> $GITHUB_OUTPUT | |
| else | |
| # Auto-determine from commit message | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if echo "$COMMIT_MSG" | grep -qiE "^(BREAKING CHANGE|feat!|fix!):"; then | |
| echo "type=major" >> $GITHUB_OUTPUT | |
| elif echo "$COMMIT_MSG" | grep -qiE "^feat:"; then | |
| echo "type=minor" >> $GITHUB_OUTPUT | |
| else | |
| echo "type=patch" >> $GITHUB_OUTPUT | |
| fi | |
| fi | |
| - name: Check for version bump skip | |
| id: check_skip | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if echo "$COMMIT_MSG" | grep -qE "\[skip version\]|\[no version\]"; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Bump version | |
| if: steps.check_skip.outputs.skip == 'false' | |
| id: bump | |
| run: | | |
| BUMP_TYPE="${{ steps.bump_type.outputs.type }}" | |
| python .github/bump_version.py $BUMP_TYPE | |
| NEW_VERSION=$(cat VERSION) | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| - name: Commit and push changes | |
| if: steps.check_skip.outputs.skip == 'false' | |
| run: | | |
| NEW_VERSION="${{ steps.bump.outputs.new_version }}" | |
| git add pyproject.toml spyhunt/__init__.py README.md VERSION | |
| # Check if there are changes to commit | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git commit -m "chore: bump version to $NEW_VERSION [skip ci]" | |
| git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION" | |
| git push origin main --tags | |
| - name: Create Release Notes | |
| if: steps.check_skip.outputs.skip == 'false' | |
| id: release_notes | |
| run: | | |
| NEW_VERSION="${{ steps.bump.outputs.new_version }}" | |
| PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -z "$PREV_TAG" ]; then | |
| COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges | head -20) | |
| else | |
| COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) | |
| fi | |
| cat > release_notes.md <<EOF | |
| ## What's Changed | |
| $COMMITS | |
| **Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v${NEW_VERSION} | |
| EOF | |
| echo "Release notes generated" | |
| - name: Create GitHub Release | |
| if: steps.check_skip.outputs.skip == 'false' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.bump.outputs.new_version }} | |
| release_name: Release v${{ steps.bump.outputs.new_version }} | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: false | |