feat: use auto commit #10
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: Release | |
| on: | |
| push: | |
| branches: [master, test1] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest | |
| - name: Run tests | |
| run: pytest tests/ -v | |
| get-next-version: | |
| needs: test | |
| uses: semantic-release-action/next-release-version/.github/workflows/next-release-version.yml@v4 | |
| update-version: | |
| needs: get-next-version | |
| runs-on: ubuntu-latest | |
| if: needs.get-next-version.outputs.new-release-published == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.11 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Update version | |
| run: | | |
| echo "Updating version..." | |
| python scripts/update_version.py --next-version ${{ needs.get-next-version.outputs.new-release-version }} | |
| - name: Commit version update | |
| uses: stefanzweifel/git-auto-commit-action@v4 | |
| with: | |
| commit_message: "chore: Update version to ${{ needs.get-next-version.outputs.new-release-version }}" | |
| file_pattern: "casbin_cli/__version__.py" | |
| commit_user_name: "GitHub Actions" | |
| commit_user_email: "[email protected]" | |
| build-binaries: | |
| needs: update-version | |
| if: needs.get-next-version.outputs.new-release-published == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux | |
| - os: windows-latest | |
| platform: windows | |
| - os: macos-latest | |
| platform: darwin | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.11 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Verify file content | |
| run: | | |
| echo "Content of __version__.py after update:" | |
| cat casbin_cli/__version__.py | |
| - name: Build binary | |
| run: python scripts/build_binaries.py --platform ${{ matrix.platform }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ matrix.platform }} | |
| path: dist/casbin-python-cli-${{ matrix.platform }}-* | |
| release: | |
| needs: [test, build-binaries] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/test1' || github.event_name == 'pull_request' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.11 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install wheel twine | |
| npm install -g semantic-release @semantic-release/changelog @semantic-release/exec @semantic-release/github @semantic-release/git | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Move binaries to dist | |
| run: | | |
| mkdir -p dist | |
| find artifacts -name "casbin-python-cli-*" -type f -exec cp {} dist/ \; | |
| ls -la dist/ | |
| - name: Semantic Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx semantic-release |