Skip to content

Commit a21b842

Browse files
committed
update yaml
1 parent a3e5742 commit a21b842

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.github/workflows/automatic-github-release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ jobs:
6565
VERSION="${{ steps.get_version.outputs.VERSION }}"
6666
RELEASE_TAG="${{ steps.calculate_release_version.outputs.RELEASE_TAG }}"
6767
# Using git log to get commits since the calculated tag
68-
RELEASE_NOTES=$(git log --pretty=format:"- %s" $(git describe --abbrev=0 --tags || echo HEAD) ..HEAD)
68+
if [[ -z $(git tag -l "$RELEASE_TAG") ]]; then
69+
RELEASE_NOTES="Initial release"
70+
else
71+
RELEASE_NOTES=$(git log --pretty=format:"- %s" "$RELEASE_TAG"..HEAD)
72+
fi
73+
6974
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
7075
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
7176
echo "EOF" >> $GITHUB_OUTPUT

.github/workflows/automatic-github-release.yml~

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,22 @@ jobs:
2424
run: |
2525
VERSION="${{ steps.get_version.outputs.VERSION }}"
2626

27-
# Calculate the release version (one less than current version in mod.json)
28-
# This uses awk to handle decimal subtraction correctly
29-
RELEASE_VERSION=$(echo "$VERSION - 0.001" | awk '{printf "%.3f", $1}') # Adjust precision as needed
27+
# Extract the parts of the version number
28+
MAJOR=$(echo "$VERSION" | cut -d'.' -f1)
29+
MINOR=$(echo "$VERSION" | cut -d'.' -f2)
30+
PATCH=$(echo "$VERSION" | cut -d'.' -f3)
31+
32+
# Calculate the RELEASE version (one less than current version in mod.json)
33+
if [[ "$PATCH" -gt 0 ]]; then
34+
RELEASE_VERSION="$MAJOR.$MINOR.$((PATCH - 1))"
35+
elif [[ "$MINOR" -gt 0 ]]; then
36+
RELEASE_VERSION="$MAJOR.$((MINOR - 1)).99" # Assuming 99 is the last patch version
37+
elif [[ "$MAJOR" -gt 0 ]]; then
38+
RELEASE_VERSION="$((MAJOR - 1)).99.99" # Assuming 99 is the last minor version
39+
else
40+
RELEASE_VERSION="0.0.0" # Or whatever makes sense for your project
41+
fi
42+
3043
RELEASE_TAG="v$RELEASE_VERSION"
3144

3245
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
@@ -49,9 +62,10 @@ jobs:
4962
id: generate_release_notes
5063
if: steps.check_tag_exists.outputs.TAG_EXISTS == 'false'
5164
run: |
65+
VERSION="${{ steps.get_version.outputs.VERSION }}"
5266
RELEASE_TAG="${{ steps.calculate_release_version.outputs.RELEASE_TAG }}"
5367
# Using git log to get commits since the calculated tag
54-
RELEASE_NOTES=$(git log $RELEASE_TAG..HEAD --pretty=format:"- %s")
68+
RELEASE_NOTES=$(git log --pretty=format:"- %s" $(git describe --abbrev=0 --tags || echo HEAD) ..HEAD)
5569
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
5670
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
5771
echo "EOF" >> $GITHUB_OUTPUT
@@ -71,6 +85,7 @@ jobs:
7185
- name: Create Tag (if it doesn't exist)
7286
if: steps.check_tag_exists.outputs.TAG_EXISTS == 'false'
7387
run: |
88+
VERSION="${{ steps.get_version.outputs.VERSION }}"
7489
RELEASE_TAG="${{ steps.calculate_release_version.outputs.RELEASE_TAG }}"
7590
git tag $RELEASE_TAG
7691
git push origin $RELEASE_TAG

0 commit comments

Comments
 (0)