|
1 |
| -name: Bump version |
2 |
| - |
| 1 | +name: Reusable Setup |
3 | 2 | on:
|
4 |
| - push: |
5 |
| - branches: |
6 |
| - - master |
7 |
| - - main |
8 |
| - workflow_dispatch: |
| 3 | + workflow_call: |
9 | 4 | inputs:
|
10 |
| - increment: |
11 |
| - description: 'Version increment (major, minor, patch)' |
| 5 | + python-version: |
12 | 6 | required: false
|
13 |
| - type: choice |
14 |
| - options: |
15 |
| - - major |
16 |
| - - minor |
17 |
| - - patch |
18 |
| - default: patch |
19 |
| - |
20 |
| -permissions: |
21 |
| - contents: write # 用于创建和推送标签 |
22 |
| - pull-requests: write # 用于创建 PR |
| 7 | + type: string |
| 8 | + default: "3.12" |
| 9 | + install-deps: |
| 10 | + required: false |
| 11 | + type: string |
| 12 | + default: "dev" # dev, docs, or none |
| 13 | + secrets: |
| 14 | + OP_SERVICE_ACCOUNT_TOKEN: |
| 15 | + required: false |
| 16 | + PERSONAL_ACCESS_TOKEN: |
| 17 | + required: false |
| 18 | + outputs: |
| 19 | + python-version: |
| 20 | + description: "The Python version that was set up" |
| 21 | + value: ${{ jobs.setup.outputs.python-version }} |
| 22 | + PERSONAL_ACCESS_TOKEN: |
| 23 | + description: "The personal access token" |
| 24 | + value: ${{ jobs.setup.outputs.PERSONAL_ACCESS_TOKEN }} |
23 | 25 |
|
24 | 26 | jobs:
|
25 | 27 | setup:
|
26 |
| - uses: ./.github/workflows/setup.yaml |
27 |
| - secrets: inherit |
28 |
| - |
29 |
| - bump-version: |
30 |
| - if: "!startsWith(github.event.head_commit.message, 'bump:')" |
31 |
| - needs: setup |
32 | 28 | runs-on: ubuntu-latest
|
33 |
| - name: "Bump version and create changelog with commitizen" |
| 29 | + outputs: |
| 30 | + python-version: ${{ steps.setup-python.outputs.python-version }} |
| 31 | + PERSONAL_ACCESS_TOKEN: ${{ steps.set-token.outputs.PERSONAL_ACCESS_TOKEN }} |
34 | 32 | steps:
|
| 33 | + - name: Load secret |
| 34 | + id: load-secret |
| 35 | + if: ${{ inputs.install-deps != 'none' }} |
| 36 | + uses: 1password/load-secrets-action@v2 |
| 37 | + with: |
| 38 | + export-env: true |
| 39 | + env: |
| 40 | + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} |
| 41 | + PERSONAL_ACCESS_TOKEN: op://shawndengdev/github_access_token/credential |
| 42 | + |
| 43 | + - name: Set token output |
| 44 | + id: set-token |
| 45 | + if: ${{ inputs.install-deps != 'none' }} |
| 46 | + run: echo "PERSONAL_ACCESS_TOKEN=${PERSONAL_ACCESS_TOKEN}" >> $GITHUB_OUTPUT |
| 47 | + |
35 | 48 | - name: Check out
|
36 | 49 | uses: actions/checkout@v4
|
37 | 50 | with:
|
38 | 51 | fetch-depth: 0
|
39 |
| - token: ${{ needs.setup.outputs.PERSONAL_ACCESS_TOKEN }} |
| 52 | + token: ${{ env.PERSONAL_ACCESS_TOKEN || github.token }} |
40 | 53 |
|
41 |
| - - id: cz |
42 |
| - name: Create bump and changelog |
43 |
| - uses: commitizen-tools/commitizen-action@master |
| 54 | + - name: Setup Python |
| 55 | + id: setup-python |
| 56 | + uses: actions/setup-python@v5 |
44 | 57 | with:
|
45 |
| - github_token: ${{ needs.setup.outputs.PERSONAL_ACCESS_TOKEN }} |
46 |
| - changelog_increment_filename: body.md |
47 |
| - increment: ${{ github.event.inputs.increment }} |
| 58 | + python-version: ${{ inputs.python-version }} |
48 | 59 |
|
49 |
| - - name: Create Release |
50 |
| - uses: softprops/action-gh-release@v2 |
| 60 | + - name: Install uv |
| 61 | + uses: astral-sh/setup-uv@v5 |
51 | 62 | with:
|
52 |
| - body_path: body.md |
53 |
| - tag_name: ${{ env.REVISION }} |
54 |
| - env: |
55 |
| - GITHUB_TOKEN: ${{ needs.setup.outputs.PERSONAL_ACCESS_TOKEN }} |
| 63 | + version: ">=0.4.0" |
| 64 | + |
| 65 | + - name: Get uv cache dir |
| 66 | + id: get-uv-cache |
| 67 | + run: echo "UV_CACHE_DIR=$(uv cache dir)" >> $GITHUB_OUTPUT |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + if: ${{ inputs.install-deps != 'none' }} |
| 71 | + run: uv sync --extra ${{ inputs.install-deps }} |
| 72 | + |
| 73 | + - name: Cache uv packages |
| 74 | + uses: actions/cache@v4 |
| 75 | + with: |
| 76 | + path: ${{ steps.get-uv-cache.outputs.UV_CACHE_DIR }} |
| 77 | + key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }} |
| 78 | + restore-keys: | |
| 79 | + ${{ runner.os }}-uv- |
0 commit comments