Skip to content

Commit fcf4fdd

Browse files
committed
ci: auto-bump VERSION constant and fix release output detection
Add @semantic-release/exec to update the VERSION constant in UintQuantizationLib.sol during the prepare phase. Include the Solidity file in the git plugin assets so it gets committed alongside CHANGELOG.md. Replace fragile output capture with before/after tag comparison. Fix soldeer-publish to checkout the release tag instead of the trigger SHA. Sync VERSION to 1.0.0 to match the current release.
1 parent dacc649 commit fcf4fdd

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
npm install --no-save \
3535
semantic-release \
3636
@semantic-release/changelog \
37+
@semantic-release/exec \
3738
@semantic-release/git \
3839
@semantic-release/github \
3940
conventional-changelog-conventionalcommits
@@ -43,18 +44,15 @@ jobs:
4344
env:
4445
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4546
run: |
46-
OUTPUT=$(npx semantic-release --dry-run 2>&1 | grep 'The next release version is' | sed 's/.*The next release version is //' || true)
47+
BEFORE_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
4748
npx semantic-release
48-
# Capture the version that was actually released
49-
RELEASED_VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || true)
50-
echo "new_release_version=$RELEASED_VERSION" >> $GITHUB_OUTPUT
51-
# Check if a new tag was created in this run
52-
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || true)
53-
PREV_SHA=$(git rev-parse HEAD~1 2>/dev/null || true)
54-
if git tag --contains $PREV_SHA | grep -q "$LATEST_TAG"; then
55-
echo "new_release_published=false" >> $GITHUB_OUTPUT
56-
else
49+
git fetch --tags
50+
AFTER_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
51+
if [ "$BEFORE_TAG" != "$AFTER_TAG" ]; then
5752
echo "new_release_published=true" >> $GITHUB_OUTPUT
53+
echo "new_release_version=${AFTER_TAG#v}" >> $GITHUB_OUTPUT
54+
else
55+
echo "new_release_published=false" >> $GITHUB_OUTPUT
5856
fi
5957
6058
soldeer-publish:
@@ -63,10 +61,10 @@ jobs:
6361
if: needs.release.outputs.new_release_published == 'true'
6462
runs-on: ubuntu-latest
6563
steps:
66-
- name: Checkout tag
64+
- name: Checkout release tag
6765
uses: actions/checkout@v4
6866
with:
69-
fetch-depth: 0
67+
ref: v${{ needs.release.outputs.new_release_version }}
7068

7169
- name: Install Foundry
7270
uses: foundry-rs/foundry-toolchain@v1

.releaserc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@
2222
"@semantic-release/changelog",
2323
{ "changelogFile": "CHANGELOG.md" }
2424
],
25+
[
26+
"@semantic-release/exec",
27+
{
28+
"prepareCmd": "sed -i 's/VERSION = \"[^\"]*\"/VERSION = \"${nextRelease.version}\"/' src/UintQuantizationLib.sol"
29+
}
30+
],
2531
[
2632
"@semantic-release/github",
2733
{ "successComment": false }
2834
],
2935
[
3036
"@semantic-release/git",
3137
{
32-
"assets": ["CHANGELOG.md"],
38+
"assets": ["CHANGELOG.md", "src/UintQuantizationLib.sol"],
3339
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
3440
}
3541
]

src/UintQuantizationLib.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ error NotAligned(uint256 value, uint256 stepSize);
3535
error BadConfig(uint256 discardedBitWidth, uint256 encodedBitWidth);
3636

3737
library UintQuantizationLib {
38-
string internal constant VERSION = "1.1.0";
38+
string internal constant VERSION = "1.0.0";
3939

4040
// -------------------------------------------------------------------------
4141
// Factory

0 commit comments

Comments
 (0)