0
0
This commit is contained in:
Marco Maatz 2025-05-16 12:41:15 +02:00
parent 1c1bcc9e60
commit d1ed2efaa6
2 changed files with 54 additions and 17 deletions

View File

@ -0,0 +1,20 @@
name: Create Tag
on:
workflow_call:
inputs:
repo:
required: true
type: string
tag:
required: true
type: string
jobs:
UpdateRelease:
runs-on: ubuntu-latest
steps:
- name: Create Tag
run: |
git config user.name "${{ vars.GIT_DEPLOY_NAME }}"
git config user.email "${{ vars.GIT_DEPLOY_MAIL }}"
git tag -a "${{ inputs.tag }}" -m "Tag automatically created by Gitea Action"
git push --follow-tags

View File

@ -20,6 +20,9 @@ on:
fileName: fileName:
required: false required: false
type: string type: string
buildChannel:
required: false
type: string
jobs: jobs:
UpdateRelease: UpdateRelease:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -37,24 +40,13 @@ jobs:
OWNER="greyhound" OWNER="greyhound"
API_TOKEN=${{ vars.PAT_TOKEN }} API_TOKEN=${{ vars.PAT_TOKEN }}
# Fetch Release prerelease="true"
tag=$(echo "${{ inputs.tag }}" | sed 's/\//%2F/g') if [ "${{ inputs.buildChannel }}" = "stable" ]; then
prerelease="false"
release=$(curl -s -H "Authorization: token $API_TOKEN" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/tags/$tag")
# Extract the ID of the Release
release_id=$(echo $release | jq -r '.id')
if [ "$release_id" == "null" ]; then
echo "No release for tag '${{ inputs.tag }}' found. Exiting."
exit 0
fi fi
echo "Found tag '${{ inputs.tag }}' release with ID: $release_id"
### MILESTONE ###
# Read Milestone and Build Url
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \ milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones") "$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
@ -67,12 +59,37 @@ jobs:
echo "Milestone named '${{ inputs.milestoneName }}' found with id $update_milestone_id." echo "Milestone named '${{ inputs.milestoneName }}' found with id $update_milestone_id."
milestoneUrl="https://gitea.greyhound-software.com/$OWNER/${{ inputs.repo }}/milestone/$update_milestone_id" milestoneUrl="https://gitea.greyhound-software.com/$OWNER/${{ inputs.repo }}/milestone/$update_milestone_id"
fi
### RELEASE ###
# Read Release and Extract the ID
tag=$(echo "${{ inputs.tag }}" | sed 's/\//%2F/g')
release=$(curl -s -H "Authorization: token $API_TOKEN" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/tags/$tag")
release_id=$(echo $release | jq -r '.id')
if [ "$release_id" == "null" ]; then
echo "No Release for tag '${{ inputs.tag }}' found. Create a new Release."
release_create=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\", \"prerelease\": \"$prerelease\"}" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases")
release_id=$(echo $release_create | jq -r '.id')
else
echo "Found Release for tag '${{ inputs.tag }}' with ID: $release_id"
release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \ release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"body\": \"$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\"}" \ -d "{\"body\": \"$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\", \"prerelease\": \"$prerelease\"}" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id") "$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id")
fi fi
if [ "${{ inputs.artifactName }}" != "null" ]; then if [ "${{ inputs.artifactName }}" != "null" ]; then
artifact_file="./${{ inputs.fileName }}" artifact_file="./${{ inputs.fileName }}"