|
24 | 24 | run: | |
25 | 25 | VERSION="${{ steps.get_version.outputs.VERSION }}" |
26 | 26 |
|
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 | + |
30 | 43 | RELEASE_TAG="v$RELEASE_VERSION" |
31 | 44 |
|
32 | 45 | echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT |
|
49 | 62 | id: generate_release_notes |
50 | 63 | if: steps.check_tag_exists.outputs.TAG_EXISTS == 'false' |
51 | 64 | run: | |
| 65 | + VERSION="${{ steps.get_version.outputs.VERSION }}" |
52 | 66 | RELEASE_TAG="${{ steps.calculate_release_version.outputs.RELEASE_TAG }}" |
53 | 67 | # 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) |
55 | 69 | echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT |
56 | 70 | echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT |
57 | 71 | echo "EOF" >> $GITHUB_OUTPUT |
|
71 | 85 | - name: Create Tag (if it doesn't exist) |
72 | 86 | if: steps.check_tag_exists.outputs.TAG_EXISTS == 'false' |
73 | 87 | run: | |
| 88 | + VERSION="${{ steps.get_version.outputs.VERSION }}" |
74 | 89 | RELEASE_TAG="${{ steps.calculate_release_version.outputs.RELEASE_TAG }}" |
75 | 90 | git tag $RELEASE_TAG |
76 | 91 | git push origin $RELEASE_TAG |
|
0 commit comments