Skip to content

Instantly share code, notes, and snippets.

@jcfr
Last active August 15, 2023 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcfr/9c0c0133c2d3fa2b029e6dd2648f7720 to your computer and use it in GitHub Desktop.
Save jcfr/9c0c0133c2d3fa2b029e6dd2648f7720 to your computer and use it in GitHub Desktop.
Convenient shell script to create an orphan release useful for hosting binary assets (e.g images) used in documentation
# SPDX-FileCopyrightText: 2023 Jean-Christophe Fillion-Robin <jcfr@kitware.com>
# SPDX-License-Identifier: BSD-3-Clause
#-----------------------------------------------------------------------------
tag_name=collection-archives
release_name=CollectionArchives
git checkout --orphan=${tag_name}
git rm -rf .
#-----------------------------------------------------------------------------
# Used for both tag title and release description
description="Binary files used in ${proj}"
#-----------------------------------------------------------------------------
org=InsightSoftwareConsortium
proj=insight-journal.org-midas-archive
#-----------------------------------------------------------------------------
cat << EOF > README.md
This branch of the repository does not contain any source code.
It is a placeholder associated with the [${release_name}](https://github.com/${org}/${proj}/releases/tag/${tag_name}) release on GitHub (GitHub only allows creating a release if it is associated with a tag or branch).
EOF
#-----------------------------------------------------------------------------
# Get the date of the oldest commit. This ensures the "DocsResources" release
# will always be listed last.
commit_date=$(git log --reverse --format=%aD origin/main | head -n 1)
echo "commit_date [${commit_date}]"
#-----------------------------------------------------------------------------
git add README.md
GIT_COMMITTER_DATE=${commit_date} git commit --date="${commit_date}" -m "DOC: Add branch for ${tag_name}
This branch of the repository does not contain any source code.
It is a placeholder associated with the [${release_name}](https://github.com/${org}/${proj}/releases/tag/${tag_name})
release on GitHub (GitHub only allows creating a release if it is
associated with a tag or branch)."
#-----------------------------------------------------------------------------
# Create tag
git tag -s -m "${description}" ${tag_name}
git push origin refs/tags/${tag_name}:refs/tags/${tag_name}
hub release create -m "${release_name}
${description}
" ${tag_name}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment