Skip to content

Commit d8d274a

Browse files
Fetch tags for Release PR job (#224)
Fetch latest release tag for this job
1 parent 3a8f8b3 commit d8d274a

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.github/workflows/release-pr.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
with:
2727
fetch-depth: 0
2828

29+
- run: git fetch --all --tags
30+
2931
- name: Check Version
3032
run: bash -c '$([[ "${{ inputs.version }}" =~ ^([0-9]+\.){2}[0-9]+ ]])'
3133

@@ -42,10 +44,10 @@ jobs:
4244
- run: yarn install --immutable
4345

4446
- name: Bump version
47+
if: ${{ inputs.version != '0.0.0' }}
4548
run: |
4649
yarn workspaces foreach version ${{ inputs.version }}
4750
yarn version ${{ inputs.version }}
48-
if: ${{ inputs.version }} != "0.0.0"
4951
5052
- name: Changelog
5153
id: create-changelog
@@ -58,9 +60,11 @@ jobs:
5860
echo "changelog_file=$TMPFILE" >> $GITHUB_OUTPUT
5961
6062
- name: lint fix
63+
if: ${{ inputs.version != '0.0.0' }}
6164
run: yarn run fix
6265

6366
- name: Create Branch
67+
if: ${{ inputs.version != '0.0.0' }}
6468
id: create-branch
6569
run: |
6670
COMMIT_SHA=$(git rev-parse --short HEAD)
@@ -71,12 +75,11 @@ jobs:
7175
git commit -m "Changelog & version bump to ${{ inputs.version }}"
7276
git push origin HEAD
7377
echo "branch_name=$BRANCH" >> $GITHUB_OUTPUT
74-
if: ${{ inputs.version }} != "0.0.0"
7578
7679
- name: Create PR
80+
if: ${{ inputs.version != '0.0.0' }}
7781
run: |
7882
gh pr create -B main -H ${{ steps.create-branch.outputs.branch_name }} --title "Release: v${{ inputs.version }}" --body-file ${{ steps.create-changelog.outputs.changelog_file }}
7983
rm ${{ steps.create-changelog.outputs.changelog_file }}
8084
env:
8185
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
if: ${{ inputs.version }} != "0.0.0"

scripts/generate_changelog.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
git tag -l --sort=-committerdate
2+
TAG=$(git tag -l --sort=-committerdate | grep -E "release-v(([0-9]+\.){2}[0-9]+)" | head -n1)
3+
14
for PACKAGE in "packages/databricks-vscode" "packages/databricks-sdk-js" "packages/databricks-vscode-types"; do
25
tmpfile=$(mktemp /tmp/generate_changelog.XXXXXX)
36
echo "## $PACKAGE" >> $tmpfile
47

5-
TAG=$(git describe --abbrev=0 --match "release-v*")
6-
if [ $? -ne 0 ]; then
7-
echo "No release tag matching pattern 'release-v*' found. Generating changelog from begining"
8-
yarn conventional-changelog -k $PACKAGE --commit-path $PACKAGE >> $tmpfile
9-
else
8+
if [[ $TAG ]]; then
109
echo "Release tag found. Generating changelog from $TAG"
1110
yarn conventional-changelog --tag-prefix="release-v" -k $PACKAGE --commit-path $PACKAGE >> $tmpfile
11+
else
12+
echo "No release tag matching pattern 'release-v*' found. Generating changelog from begining"
13+
yarn conventional-changelog -k $PACKAGE --commit-path $PACKAGE >> $tmpfile
1214
fi
1315

1416
cat $tmpfile | grep -Ev "Release: v.+" >> $2

0 commit comments

Comments
 (0)