|
1 | 1 | name: Release |
2 | 2 |
|
| 3 | +# d-party モノレポ root の release ワークフローから統一バージョンを受け取って起動される。 |
| 4 | +# pyproject.toml の version を書き換えて main へコミットし、タグ + GitHub Release を作る。 |
| 5 | + |
3 | 6 | on: |
4 | 7 | workflow_dispatch: |
5 | 8 | inputs: |
6 | 9 | version: |
7 | | - description: "Next Version" |
| 10 | + description: "Release version (X.Y.Z)" |
8 | 11 | required: true |
9 | 12 | default: "x.y.z" |
10 | 13 | release_note: |
11 | 14 | description: "release note" |
12 | 15 | required: false |
| 16 | + |
13 | 17 | jobs: |
14 | 18 | release: |
15 | 19 | runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: write |
16 | 22 | steps: |
17 | 23 | - uses: actions/checkout@v4 |
18 | | - - name: Create Release |
19 | | - id: create_release |
20 | | - uses: actions/create-release@v1 |
| 24 | + with: |
| 25 | + ref: main |
| 26 | + |
| 27 | + - name: Bump version and commit |
21 | 28 | env: |
22 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + VERSION: ${{ github.event.inputs.version }} |
| 30 | + run: | |
| 31 | + set -euo pipefail |
| 32 | + python3 - <<'EOF' |
| 33 | + import os, re |
| 34 | + v = os.environ["VERSION"] |
| 35 | + path = "pyproject.toml" |
| 36 | + s = open(path, encoding="utf-8").read() |
| 37 | + s = re.sub(r'(?m)^version\s*=\s*".*"$', f'version = "{v}"', s, count=1) |
| 38 | + open(path, "w", encoding="utf-8").write(s) |
| 39 | + EOF |
| 40 | + git config user.name "github-actions[bot]" |
| 41 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 42 | + git add pyproject.toml |
| 43 | + git commit -m "chore: bump version to v${VERSION} [skip ci]" |
| 44 | + git push origin HEAD:main |
| 45 | +
|
| 46 | + - name: Create GitHub Release |
| 47 | + uses: softprops/action-gh-release@v2 |
23 | 48 | with: |
24 | 49 | tag_name: v${{ github.event.inputs.version }} |
25 | | - release_name: Release v${{ github.event.inputs.version }} |
26 | | - body: | |
27 | | - ${{ github.event.inputs.release_note }} |
28 | | - draft: false |
29 | | - prerelease: false |
| 50 | + name: Release v${{ github.event.inputs.version }} |
| 51 | + body: ${{ github.event.inputs.release_note }} |
| 52 | + generate_release_notes: true |
| 53 | + target_commitish: main |
0 commit comments