|
1 | | -name: Publish on PR merge |
| 1 | +name: Publish release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: |
5 | | - types: [opened, synchronize, reopened, labeled, closed] |
| 5 | + types: [closed] |
6 | 6 | branches: |
7 | 7 | - main |
8 | 8 |
|
9 | 9 | permissions: |
10 | 10 | contents: write |
11 | 11 | id-token: write |
12 | | - pull-requests: write |
13 | 12 |
|
14 | 13 | jobs: |
15 | | - update-version-and-changelog: |
16 | | - # Run only when a release label is added (not on every push) |
17 | | - if: | |
18 | | - github.event.action == 'labeled' && |
19 | | - github.event.pull_request.merged == false && ( |
20 | | - contains(github.event.pull_request.labels.*.name, 'release:major') || |
21 | | - contains(github.event.pull_request.labels.*.name, 'release:minor') || |
22 | | - contains(github.event.pull_request.labels.*.name, 'release:patch') |
23 | | - ) |
| 14 | + publish: |
| 15 | + if: github.event.pull_request.merged == true |
24 | 16 | runs-on: ubuntu-latest |
25 | | - |
26 | | - steps: |
27 | | - - name: Check out PR branch |
28 | | - uses: actions/checkout@v4 |
29 | | - with: |
30 | | - ref: ${{ github.head_ref }} |
31 | | - fetch-depth: 0 |
32 | | - token: ${{ secrets.GITHUB_TOKEN }} |
33 | | - |
34 | | - - name: Set up Python |
35 | | - uses: actions/setup-python@v5 |
36 | | - with: |
37 | | - python-version: "3.13" |
38 | | - |
39 | | - - name: Install tools |
40 | | - run: | |
41 | | - pip install bump-my-version build pandoc |
42 | | - sudo apt-get update |
43 | | - sudo apt-get install -y pandoc |
44 | | - cargo install git-cliff |
45 | | -
|
46 | | - - name: Set up Git user |
47 | | - run: | |
48 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
49 | | - git config --local user.name "github-actions[bot]" |
50 | | -
|
51 | | - - name: Determine version bump type |
52 | | - id: bump |
53 | | - run: | |
54 | | - if [[ "${{ contains(github.event.pull_request.labels.*.name, 'release:major') }}" == "true" ]]; then |
55 | | - echo "type=major" >> $GITHUB_OUTPUT |
56 | | - elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'release:minor') }}" == "true" ]]; then |
57 | | - echo "type=minor" >> $GITHUB_OUTPUT |
58 | | - else |
59 | | - echo "type=patch" >> $GITHUB_OUTPUT |
60 | | - fi |
61 | | -
|
62 | | - - name: Bump version |
63 | | - run: bump-my-version bump ${{ steps.bump.outputs.type }} |
64 | | - env: |
65 | | - BMV_ALLOW_DIRTY: "true" |
66 | | - |
67 | | - - name: Extract version |
68 | | - id: version |
69 | | - run: | |
70 | | - VERSION=$(bump-my-version show current) |
71 | | - echo "Extracted version: $VERSION" |
72 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
73 | | -
|
74 | | - - name: Generate changelog |
75 | | - run: | |
76 | | - git cliff -o CHANGELOG.md |
77 | | - echo "Generated changelog for version ${{ steps.version.outputs.version }}" |
78 | | -
|
79 | | -
|
80 | | - - name: Commit and push changes to PR branch |
81 | | - run: | |
82 | | - git add . |
83 | | - git commit -m "chore: bump version to ${{ steps.version.outputs.version }} and update changelog [skip ci]" || echo "No changes to commit" |
84 | | - git push origin HEAD:${{ github.head_ref }} |
85 | | -
|
86 | | - publish-after-merge: |
87 | | - # Run only after PR is merged with release labels |
88 | | - if: | |
89 | | - github.event.pull_request.merged == true && ( |
90 | | - contains(github.event.pull_request.labels.*.name, 'release:major') || |
91 | | - contains(github.event.pull_request.labels.*.name, 'release:minor') || |
92 | | - contains(github.event.pull_request.labels.*.name, 'release:patch') |
93 | | - ) |
94 | | - runs-on: ubuntu-latest |
95 | | - |
96 | 17 | steps: |
97 | 18 | - name: Check out repository |
98 | 19 | uses: actions/checkout@v4 |
|
0 commit comments