Skip to content

Commit 962eca3

Browse files
[release] add changelog to release draft (#47)
1 parent 006a544 commit 962eca3

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

.github/workflows/main.yml

+25-16
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ jobs:
3838
GeneratedProtobuf
3939
MySqlConnectorExample
4040
NpgsqlExample
41-
41+
42+
4243
ci:
4344
name: CI
4445
runs-on: ${{ matrix.os }}
@@ -109,38 +110,41 @@ jobs:
109110
run: |
110111
chmod +x ./scripts/run_tests.sh
111112
./scripts/run_tests.sh
113+
112114
- name: upload wasm plugin as artifact
113115
uses: actions/upload-artifact@v2
114-
if: github.ref == 'refs/heads/add-automatic-release' && contains(github.event.head_commit.message, '[release]')
116+
if: github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[release]')
115117
with:
116118
name: wasm-file
117119
path: dist/plugin.wasm
118120

119121
release:
120122
name: Release test
121123
runs-on: ubuntu-latest
122-
if: github.ref == 'refs/heads/add-automatic-release' && contains(github.event.head_commit.message, '[release]')
124+
if: github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[release]')
123125
needs: [ci]
124126
steps:
125127
- name: Check out Git repository
126128
uses: actions/checkout@v4
127129
with:
128130
fetch-depth: 0 # fetches all history for all tags and branches
131+
129132
- uses: actions/download-artifact@v2
130133
with:
131134
name: wasm-file
135+
132136
- name: Bump version and create new tag
133137
id: bump_version
134138
run: |
135-
echo "Extract the last tag version"
136-
LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
137-
echo "Last tag version: $LAST_TAG"
139+
set -ex
140+
echo "Extract the latest tag version"
141+
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
142+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
143+
144+
echo "latest tag version: $LATEST_TAG"
138145
LATEST_COMMIT_MSG=$(git log -1 --pretty=%B)
139146
140-
# Initialize the default version bump type to patch
141-
BUMP_TYPE="patch"
142-
143-
# Check the latest commit message for [major] or [minor]
147+
BUMP_TYPE="patch" # Initialize the default version bump type to patch
144148
if [[ $LATEST_COMMIT_MSG == *"[major]"* ]]; then
145149
BUMP_TYPE="major"
146150
elif [[ $LATEST_COMMIT_MSG == *"[minor]"* ]]; then
@@ -150,13 +154,13 @@ jobs:
150154
# Bump the version based on the type
151155
case $BUMP_TYPE in
152156
"major")
153-
NEW_TAG=$(echo $LAST_TAG | awk -F. '{OFS="."; $1="v" substr($1,2)+1; $2="0"; $3="0"; print}')
157+
NEW_TAG=$(echo $LATEST_TAG | awk -F. '{OFS="."; $1="v" substr($1,2)+1; $2="0"; $3="0"; print}')
154158
;;
155159
"minor")
156-
NEW_TAG=$(echo $LAST_TAG | awk -F. '{OFS="."; $2=$2+1; $3="0"; print}')
160+
NEW_TAG=$(echo $LATEST_TAG | awk -F. '{OFS="."; $2=$2+1; $3="0"; print}')
157161
;;
158162
"patch")
159-
NEW_TAG=$(echo $LAST_TAG | awk -F. '{OFS="."; $3=$3+1; print}')
163+
NEW_TAG=$(echo $LATEST_TAG | awk -F. '{OFS="."; $3=$3+1; print}')
160164
;;
161165
esac
162166
@@ -166,16 +170,21 @@ jobs:
166170
# Create a new tag
167171
git tag $NEW_TAG
168172
git push origin $NEW_TAG
169-
173+
170174
- name: Calculate sha256
171175
run: |
172176
SHA256_HASH=$(sha256sum plugin.wasm | awk '{ print $1 }')
173177
echo "SHA256_HASH=$SHA256_HASH" >> $GITHUB_ENV
174178
echo "The calculated sha256 is $SHA256_HASH"
175-
- name: create relaese draft
179+
180+
- name: Create release draft
176181
run: |
182+
LATEST_TAG=${{ env.LATEST_TAG }}
177183
NEW_TAG=${{ env.NEW_TAG }}
178184
SHA256_HASH=${{ env.SHA256_HASH }}
185+
186+
PREVIOUS_TAG=$(git rev-list -n 1 $LATEST_TAG)
187+
CHANGE_LOG=$(git --no-pager log $PREVIOUS_TAG..HEAD --pretty=format:'%h - %an, %ar : %s')
179188
180189
# Define the release notes template
181190
RELEASE_NOTES=$(cat <<EOF
@@ -192,7 +201,7 @@ jobs:
192201
sha256: $SHA256_HASH
193202
\`\`\`
194203
## Changelog
195-
* ADD CHANGES HERE...
204+
$CHANGE_LOG
196205
197206
## Contributors
198207
* @doron050 @SockworkOrange

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The release flow in this repo follows the semver conventions, building tag as `v
9393
9494
* In order to create a release you need to add `[release]` somewhere in your commit message when merging to master
9595
96-
### Version bumping (build on tags)
96+
### Version bumping (built on tags)
9797
**By default, the release script will bump the patch version.**, by adding `[release]` to your commit message the release script will create a new tag with `v[major].[minor].[patch]+1`.
9898
* Bump `minor` version by adding `[minor]` to your commit message resulting in a new tag with `v[major].[minor]+1.0`<br/>
9999
* Bump `major` version by adding `[major]` to your commit message resulting in a new tag with `v[major]+1.0.0`

0 commit comments

Comments
 (0)