Skip to content

Commit

Permalink
Merge pull request #58 from tj-actions/feat/add-support-for-downloadi…
Browse files Browse the repository at this point in the history
…ng-release-assets
  • Loading branch information
jackton1 authored Dec 18, 2022
2 parents 24cf826 + cb2c44c commit bd6f00f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ git fetch "$INPUTS_REMOTE" +refs/tags/*:refs/tags/*

NEW_TAG=${GITHUB_REF/refs\/tags\//}
MAJOR_VERSION=$(echo "$NEW_TAG" | cut -d. -f1)
RELEASE_ASSETS_DIR=$(mktemp -d)

for tag in $(git tag -l --sort=-version:refname "$MAJOR_VERSION.*"); do
echo "Adding $tag to release notes"
Expand All @@ -19,16 +20,21 @@ for tag in $(git tag -l --sort=-version:refname "$MAJOR_VERSION.*"); do
gh release view "$tag" --json body --jq '.body'
printf "\n---\n\n"
} >> "$INPUTS_RELEASE_NOTES_FILE"

# Download the release assets
gh release download "$tag" --dir "$RELEASE_ASSETS_DIR"
done

if [[ -f "$INPUTS_RELEASE_NOTES_FILE" ]]; then
if gh release view "$MAJOR_VERSION" > /dev/null 2>&1; then
gh release edit "$MAJOR_VERSION" --notes-file "$INPUTS_RELEASE_NOTES_FILE" --title "$MAJOR_VERSION"
gh release upload --clobber "$MAJOR_VERSION" "$RELEASE_ASSETS_DIR"/*

# Re-tag the major version using the latest tag
git tag -f "$MAJOR_VERSION" "$NEW_TAG"
git push -f "$INPUTS_REMOTE" "$MAJOR_VERSION"
else
gh release create "$MAJOR_VERSION" --notes-file "$INPUTS_RELEASE_NOTES_FILE" --title "$MAJOR_VERSION"
gh release create "$MAJOR_VERSION" --notes-file "$INPUTS_RELEASE_NOTES_FILE" --title "$MAJOR_VERSION" "$RELEASE_ASSETS_DIR"/*
fi
fi

Expand All @@ -43,3 +49,4 @@ EOF
fi

rm -f "$INPUTS_RELEASE_NOTES_FILE" || true
rm -rf "$RELEASE_ASSETS_DIR" || true

0 comments on commit bd6f00f

Please sign in to comment.