Skip to content

Commit 15b023c

Browse files
authored
Upgrade Script to v4 artifact version and add changelog (#187)
1 parent 010f856 commit 15b023c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

.github/workflows/build-release-import-script.yml

+24-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
fi
3939
go build -o "${output_name}" ./import/import_script.go
4040
- name: Upload artifact
41-
uses: actions/upload-artifact@v3
41+
uses: actions/upload-artifact@v4
4242
with:
4343
name: binaries
4444
path: terraform-provider-astro-import-script_*
@@ -65,14 +65,31 @@ jobs:
6565
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
6666

6767
- name: Download artifacts
68-
uses: actions/download-artifact@v3
68+
uses: actions/download-artifact@v4
6969
with:
7070
name: binaries
7171

7272
- name: Get the version
7373
id: get_version
7474
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
7575

76+
- name: Generate Changelog
77+
id: changelog
78+
run: |
79+
# Extract previous tag
80+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
81+
82+
# Generate changelog with PR numbers and authors in the desired format
83+
CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"* %s by @%an in #%b" | \
84+
sed -E 's/\(#[0-9]+\)//g' | \ # Remove PR numbers if they exist in commit message
85+
sed -E 's/ */ /g' | \ # Clean up extra spaces
86+
sed -E 's/ in #$//') # Remove trailing "in #" if no PR number
87+
88+
# Store changelog in output
89+
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
90+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
91+
echo "EOF" >> $GITHUB_OUTPUT
92+
7693
- name: Create Release
7794
id: create_release
7895
uses: actions/create-release@v1
@@ -81,6 +98,11 @@ jobs:
8198
with:
8299
tag_name: ${{ steps.get_version.outputs.VERSION }}
83100
release_name: Astro Import Script ${{ steps.get_version.outputs.VERSION }}
101+
body: |
102+
## What's Changed
103+
${{ steps.changelog.outputs.CHANGELOG }}
104+
105+
For full changelog, see [here](https://github.com/${{ github.repository }}/compare/${{ env.PREVIOUS_TAG }}...${{ steps.get_version.outputs.VERSION }})
84106
draft: false
85107
prerelease: false
86108

0 commit comments

Comments
 (0)