Skip to content

Commit

Permalink
πŸ› οΈ Enhance auto-release workflow with improved variable handling
Browse files Browse the repository at this point in the history
β€’ πŸ”’ Added quotes to prevent potential issues with special characters in variables
β€’ πŸ”„ Updated release creation step to use `softprops/action-gh-release@v1`
β€’ πŸ› Fixed `release_id` reference in `updateRelease` function
β€’ πŸ’‘ Improved code readability with consistent string interpolation
β€’ πŸ“¦ Prepared structure for including files in the release (commented out for now)

These changes enhance the reliability and flexibility of the auto-release workflow, ensuring better handling of variables and providing a more robust release creation process.
  • Loading branch information
yuri-val committed Oct 18, 2024
1 parent ed5cf32 commit 646296f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ jobs:
id: get_base_version
shell: bash
run: |
BASE_VERSION=$(echo ${{ steps.get_tag.outputs.TAG }} | cut -d. -f1)
BASE_VERSION=$(echo "${{ steps.get_tag.outputs.TAG }}" | cut -d. -f1)
echo "BASE_VERSION=${BASE_VERSION}" >> $GITHUB_OUTPUT
- name: Get previous tag
id: get_previous_tag
shell: bash
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${{ steps.get_tag.outputs.TAG }}^ || echo "")
PREVIOUS_TAG=$(git describe --tags --abbrev=0 "${{ steps.get_tag.outputs.TAG }}"^ || echo "")
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
- name: Generate changelog
id: generate_changelog
shell: bash
run: |
if [ -n "${{ steps.get_previous_tag.outputs.PREVIOUS_TAG }}" ]; then
CHANGELOG=$(git log --pretty=format:"- %s" ${{ steps.get_previous_tag.outputs.PREVIOUS_TAG }}..${{ steps.get_tag.outputs.TAG }})
CHANGELOG=$(git log --pretty=format:"- %s" "${{ steps.get_previous_tag.outputs.PREVIOUS_TAG }}..${{ steps.get_tag.outputs.TAG }}")
else
CHANGELOG=$(git log --pretty=format:"- %s" ${{ steps.get_tag.outputs.TAG }})
CHANGELOG=$(git log --pretty=format:"- %s" "${{ steps.get_tag.outputs.TAG }}")
fi
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
Expand All @@ -54,13 +54,13 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const baseVersion = '${{ steps.get_base_version.outputs.BASE_VERSION }}';
const fullVersion = '${{ steps.get_tag.outputs.TAG }}';
const baseVersion = `${{ steps.get_base_version.outputs.BASE_VERSION }}`;
const fullVersion = `${{ steps.get_tag.outputs.TAG }}`;
const changelog = `${{ steps.generate_changelog.outputs.CHANGELOG }}`;
try {
// Try to get the existing release
await github.rest.repos.getReleaseByTag({
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: baseVersion
Expand All @@ -70,7 +70,7 @@ jobs:
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
release_id: release.id,
tag_name: baseVersion,
name: `Base Release ${baseVersion}`,
body: `This is the base release for ${baseVersion}. Latest version: ${fullVersion}\n\nChangelog:\n${changelog}`,
Expand All @@ -95,14 +95,16 @@ jobs:
}
- name: Create Full Version Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
files: |
# Add any files you want to include in the release
tag_name: ${{ steps.get_tag.outputs.TAG }}
release_name: Release ${{ steps.get_tag.outputs.TAG }}
name: Release ${{ steps.get_tag.outputs.TAG }}
body: |
Changes in this Release:
${{ steps.generate_changelog.outputs.CHANGELOG }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 646296f

Please sign in to comment.