Last active
August 15, 2023 21:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2023 Jean-Christophe Fillion-Robin <[email protected]> | |
# 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