_renameTag-internal_to_internal-date #16
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
# Intended to designate an build (eg. of 'ubcp')that was found of sufficient quality for internal inclusion with other projects as a historic example. | |
# If compatible or successful as documented (eg. specific features tested) or expected (ie. all essential features tested), the next step would be to tag as 'certified' with a date. | |
# ATTRIBUTION-AI - Largely attributable to ChatGPT GPT-4 2023-06-26 . | |
name: _renameTag-internal_to_internal-date | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions | |
permissions: | |
actions: write | |
checks: read | |
contents: write | |
deployments: read | |
issues: read | |
packages: read | |
pull-requests: read | |
repository-projects: read | |
security-events: none | |
statuses: read | |
on: | |
workflow_dispatch: | |
#inputs: | |
#source_tag: | |
#description: 'Source Tag' | |
#required: true | |
#target_tag: | |
#description: 'Target Tag' | |
#required: true | |
jobs: | |
copy-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # we need fetch-depth: 0 to fetch all tags | |
- name: Update release | |
run: | | |
_safeEcho () | |
{ | |
printf '%s' "$1"; | |
shift; | |
[[ "$@" == "" ]] && return 0; | |
local currentArg; | |
for currentArg in "$@"; | |
do | |
printf '%s' " "; | |
printf '%s' "$currentArg"; | |
done; | |
return 0 | |
} | |
# Fetch all releases | |
releases=$(gh api repos/${{ github.repository }}/releases) | |
# Find the tag name for the release by its name | |
tag_name=$(echo "$releases" | jq -r '.[] | select(.name == "internal") | .tag_name' | sed 's/\\n//g' | sort -n -r | head -n 1) | |
# Find the tag name for the release by its name | |
body=$(echo "$releases" | jq -r '.[] | select(.tag_name == "$tag_name") | .body' | tr -dc 'a-zA-Z0-9.:\=\_\-/%+\ \n') | |
# Edit the release using its tag name | |
_safeEcho "$body" | gh release edit "$tag_name" --title "internal"-$(date +'%Y-%m-%d') --notes - | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |