Skip to content

Commit 9ad3543

Browse files
Update bump_version.yaml
1 parent beec319 commit 9ad3543

File tree

1 file changed

+39
-63
lines changed

1 file changed

+39
-63
lines changed

.github/workflows/bump_version.yaml

Lines changed: 39 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,55 @@
1-
name: Reusable Setup
1+
name: Bump version
2+
23
on:
3-
workflow_call:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
workflow_dispatch:
49
inputs:
5-
python-version:
6-
required: false
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:
10+
increment:
11+
description: 'Version increment (major, minor, patch)'
1712
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 }}
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
2523

2624
jobs:
2725
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
2832
runs-on: ubuntu-latest
29-
outputs:
30-
python-version: ${{ steps.setup-python.outputs.python-version }}
31-
PERSONAL_ACCESS_TOKEN: ${{ steps.set-token.outputs.PERSONAL_ACCESS_TOKEN }}
33+
name: "Bump version and create changelog with commitizen"
3234
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-
4835
- name: Check out
4936
uses: actions/checkout@v4
5037
with:
5138
fetch-depth: 0
52-
token: ${{ env.PERSONAL_ACCESS_TOKEN || github.token }}
39+
token: ${{ needs.setup.outputs.PERSONAL_ACCESS_TOKEN }}
5340

54-
- name: Setup Python
55-
id: setup-python
56-
uses: actions/setup-python@v5
41+
- id: cz
42+
name: Create bump and changelog
43+
uses: commitizen-tools/commitizen-action@master
5744
with:
58-
python-version: ${{ inputs.python-version }}
45+
github_token: ${{ needs.setup.outputs.PERSONAL_ACCESS_TOKEN }}
46+
changelog_increment_filename: body.md
47+
increment: ${{ github.event.inputs.increment }}
5948

60-
- name: Install uv
61-
uses: astral-sh/setup-uv@v5
49+
- name: Create Release
50+
uses: softprops/action-gh-release@v2
6251
with:
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-
52+
body_path: body.md
53+
tag_name: ${{ env.REVISION }}
54+
env:
55+
GITHUB_TOKEN: ${{ needs.setup.outputs.PERSONAL_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)