Skip to content

Commit 836c7d2

Browse files
committed
chore: release improvements
1 parent 276f1b1 commit 836c7d2

1 file changed

Lines changed: 50 additions & 28 deletions

File tree

.github/workflows/release.yaml

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,95 @@ name: Release
33
on:
44
workflow_dispatch:
55

6-
permissions:
7-
contents: write
8-
issues: write
9-
pull-requests: write
10-
116
jobs:
127
github_release:
138
name: GitHub Release
14-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-24.04
10+
permissions:
11+
contents: write
1512
outputs:
16-
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
1713
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
14+
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
1815
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v4
16+
- uses: actions/checkout@v4
2117
with:
2218
fetch-depth: 0
23-
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
19+
persist-credentials: false
20+
ref: main
2421

2522
- name: Setup Node.js
2623
uses: actions/setup-node@v4
2724
with:
2825
node-version: "lts/*"
2926

30-
- name: Install semantic-release plugins
27+
- name: Install semantic release and plugins
3128
run: |
32-
npm install -g semantic-release \
33-
@semantic-release/commit-analyzer \
34-
@semantic-release/release-notes-generator \
29+
npm install -g semantic-release@v24.2.1 \
30+
conventional-changelog-cli \
31+
conventional-changelog-conventionalcommits \
32+
@semantic-release/changelog \
3533
@semantic-release/exec \
36-
@semantic-release/github \
3734
@semantic-release/git \
38-
conventional-changelog-conventionalcommits
39-
40-
- name: Semantic Release (dry-run)
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
43-
run: npx semantic-release --dry-run
35+
@semantic-release/github
4436
45-
- name: Semantic Release
37+
- name: Semantic Release Dry Run
4638
id: semantic
39+
run: |
40+
dry_run_output=$(semantic-release --dry-run 2>&1 || true)
41+
42+
echo "$dry_run_output"
43+
44+
# Check if there are no changes
45+
if [[ "$dry_run_output" == *"no new version is released"* ]]; then
46+
echo "No new release needed"
47+
echo "new_release_published=false" >> $GITHUB_OUTPUT
48+
exit 0
49+
fi
50+
51+
# Extract version from dry run output
52+
version=$(echo "$dry_run_output" | grep -oP "The next release version is \K[0-9]+\.[0-9]+\.[0-9]+")
53+
if [ -z "$version" ]; then
54+
echo "::error ::Could not determine version"
55+
exit 1
56+
fi
57+
58+
echo "new_release_version=$version" >> $GITHUB_OUTPUT
59+
60+
# Run actual release
61+
if semantic-release; then
62+
echo "Release successful"
63+
echo "new_release_published=true" >> $GITHUB_OUTPUT
64+
else
65+
echo "Release failed"
66+
exit 1
67+
fi
4768
env:
69+
CI: true
4870
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
49-
run: npx semantic-release
5071

5172
publish:
5273
name: Publish to PyPI
53-
runs-on: ubuntu-latest
5474
needs: github_release
5575
if: needs.github_release.outputs.new_release_published == 'true'
76+
runs-on: ubuntu-24.04
5677
steps:
5778
- name: Checkout
5879
uses: actions/checkout@v4
5980
with:
6081
ref: main
61-
fetch-depth: 0
6282

63-
- name: Pull latest changes
83+
- name: Fetch changes on main
6484
run: git pull origin main
6585

6686
- name: Setup Python
6787
uses: actions/setup-python@v5
6888
with:
6989
python-version: "3.10"
7090

71-
- name: Install build tools
72-
run: pip install build twine
91+
- name: Install dependencies
92+
run: |
93+
python -m pip install --upgrade pip
94+
python -m pip install build twine
7395
7496
- name: Build package
7597
run: python -m build

0 commit comments

Comments
 (0)