lf
This commit is contained in:
parent
34da23de0a
commit
c1e279e9f2
@ -1,80 +1,80 @@
|
||||
name: Close Milestone Issues
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
repo:
|
||||
required: true
|
||||
type: string
|
||||
milestone:
|
||||
required: true
|
||||
type: string
|
||||
jobs:
|
||||
close_issues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: List and close issues
|
||||
run: |
|
||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||
OWNER="greyhound"
|
||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||
|
||||
NEW_LABEL_ID="32"
|
||||
FILTER_LABEL_ID="37"
|
||||
|
||||
# Fetch milestones from the repository
|
||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
# Extract the ID of the ${{ inputs.milestone }} milestone
|
||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestone }}") | .id')
|
||||
|
||||
if [ -z "$update_milestone_id" ]; then
|
||||
echo "No milestone named '${{ inputs.milestone }}' found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Reading the Issues with the given Milestone
|
||||
echo "Milestone Id '$update_milestone_id'"
|
||||
echo "Reading issues with Url '$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestone=$update_milestone_id'"
|
||||
issues=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestones=$update_milestone_id")
|
||||
|
||||
for issue_number in $(echo "$issues" | jq -r '.[].number'); do
|
||||
echo "Processing issue #$issue_number"
|
||||
|
||||
# Debug: Output the full response for the current issue
|
||||
issue_details=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
||||
echo "Issue details: $issue_details"
|
||||
|
||||
# Get the current labels for the issue (now correctly parsing the JSON structure)
|
||||
current_labels=$(echo "$issue_details" | jq '[.labels[].id]')
|
||||
|
||||
# Check if the issue has the specific label you're filtering by
|
||||
has_filter_label=$(echo "$current_labels" | jq --argjson filter_label $FILTER_LABEL_ID 'index($filter_label) != null')
|
||||
|
||||
if [ "$has_filter_label" = "true" ]; then
|
||||
echo "Issue #$issue_number has the label $FILTER_LABEL_ID and milestone ${{ inputs.milestone }}"
|
||||
|
||||
# Debug: Output current labels
|
||||
echo "Current labels for issue #$issue_number: $current_labels"
|
||||
|
||||
# Update the issue
|
||||
updateResponse=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"state\": \"closed\"}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
||||
echo "ISSUE update response: $updateResponse"
|
||||
|
||||
# Update the issue labels
|
||||
labelResponse=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"labels\": [$NEW_LABEL_ID]}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number/labels")
|
||||
|
||||
echo "ISSUE Label update response code: $labelResponse"
|
||||
else
|
||||
echo "Issue #$issue_number does not have the label $FILTER_LABEL_ID, skipping..."
|
||||
fi
|
||||
done
|
||||
name: Close Milestone Issues
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
repo:
|
||||
required: true
|
||||
type: string
|
||||
milestone:
|
||||
required: true
|
||||
type: string
|
||||
jobs:
|
||||
close_issues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: List and close issues
|
||||
run: |
|
||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||
OWNER="greyhound"
|
||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||
|
||||
NEW_LABEL_ID="32"
|
||||
FILTER_LABEL_ID="37"
|
||||
|
||||
# Fetch milestones from the repository
|
||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
# Extract the ID of the ${{ inputs.milestone }} milestone
|
||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestone }}") | .id')
|
||||
|
||||
if [ -z "$update_milestone_id" ]; then
|
||||
echo "No milestone named '${{ inputs.milestone }}' found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Reading the Issues with the given Milestone
|
||||
echo "Milestone Id '$update_milestone_id'"
|
||||
echo "Reading issues with Url '$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestone=$update_milestone_id'"
|
||||
issues=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestones=$update_milestone_id")
|
||||
|
||||
for issue_number in $(echo "$issues" | jq -r '.[].number'); do
|
||||
echo "Processing issue #$issue_number"
|
||||
|
||||
# Debug: Output the full response for the current issue
|
||||
issue_details=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
||||
echo "Issue details: $issue_details"
|
||||
|
||||
# Get the current labels for the issue (now correctly parsing the JSON structure)
|
||||
current_labels=$(echo "$issue_details" | jq '[.labels[].id]')
|
||||
|
||||
# Check if the issue has the specific label you're filtering by
|
||||
has_filter_label=$(echo "$current_labels" | jq --argjson filter_label $FILTER_LABEL_ID 'index($filter_label) != null')
|
||||
|
||||
if [ "$has_filter_label" = "true" ]; then
|
||||
echo "Issue #$issue_number has the label $FILTER_LABEL_ID and milestone ${{ inputs.milestone }}"
|
||||
|
||||
# Debug: Output current labels
|
||||
echo "Current labels for issue #$issue_number: $current_labels"
|
||||
|
||||
# Update the issue
|
||||
updateResponse=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"state\": \"closed\"}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
||||
echo "ISSUE update response: $updateResponse"
|
||||
|
||||
# Update the issue labels
|
||||
labelResponse=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"labels\": [$NEW_LABEL_ID]}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number/labels")
|
||||
|
||||
echo "ISSUE Label update response code: $labelResponse"
|
||||
else
|
||||
echo "Issue #$issue_number does not have the label $FILTER_LABEL_ID, skipping..."
|
||||
fi
|
||||
done
|
||||
|
@ -1,58 +1,58 @@
|
||||
name: Milestone Rename
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
repo:
|
||||
required: true
|
||||
type: string
|
||||
currentName:
|
||||
required: true
|
||||
type: string
|
||||
newName:
|
||||
required: true
|
||||
type: string
|
||||
jobs:
|
||||
rename:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Rename
|
||||
run: |
|
||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||
OWNER="greyhound"
|
||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||
|
||||
# Fetch milestones from the repository
|
||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
# Extract the ID of the ${{ inputs.currentName }} milestone
|
||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.currentName }}") | .id')
|
||||
|
||||
if [ -z "$update_milestone_id" ]; then
|
||||
echo "No milestone named '${{ inputs.currentName }}' found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found '${{ inputs.currentName }}' milestone with ID: $update_milestone_id"
|
||||
|
||||
echo "Rename the '${{ inputs.currentName }}' milestone to '${{ inputs.newName }}"
|
||||
new_name="${{ inputs.newName }}"
|
||||
milestone_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"title\": \"$new_name\", \"state\": \"closed\"}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones/$update_milestone_id")
|
||||
|
||||
echo "Renamed '${{ inputs.currentName }}' milestone to $new_name: $milestone_update"
|
||||
|
||||
# Create a new milestone named "${{ inputs.currentName }}"
|
||||
|
||||
milestone_data=$(jq -n \
|
||||
--arg title "${{ inputs.currentName }}" \
|
||||
'{"title": $title}')
|
||||
|
||||
response=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$milestone_data" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
name: Milestone Rename
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
repo:
|
||||
required: true
|
||||
type: string
|
||||
currentName:
|
||||
required: true
|
||||
type: string
|
||||
newName:
|
||||
required: true
|
||||
type: string
|
||||
jobs:
|
||||
rename:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Rename
|
||||
run: |
|
||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||
OWNER="greyhound"
|
||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||
|
||||
# Fetch milestones from the repository
|
||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
# Extract the ID of the ${{ inputs.currentName }} milestone
|
||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.currentName }}") | .id')
|
||||
|
||||
if [ -z "$update_milestone_id" ]; then
|
||||
echo "No milestone named '${{ inputs.currentName }}' found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found '${{ inputs.currentName }}' milestone with ID: $update_milestone_id"
|
||||
|
||||
echo "Rename the '${{ inputs.currentName }}' milestone to '${{ inputs.newName }}"
|
||||
new_name="${{ inputs.newName }}"
|
||||
milestone_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"title\": \"$new_name\", \"state\": \"closed\"}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones/$update_milestone_id")
|
||||
|
||||
echo "Renamed '${{ inputs.currentName }}' milestone to $new_name: $milestone_update"
|
||||
|
||||
# Create a new milestone named "${{ inputs.currentName }}"
|
||||
|
||||
milestone_data=$(jq -n \
|
||||
--arg title "${{ inputs.currentName }}" \
|
||||
'{"title": $title}')
|
||||
|
||||
response=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$milestone_data" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
echo "Created new '${{ inputs.currentName }}' milestone: $response"
|
@ -1,77 +1,77 @@
|
||||
name: Parse Version Number
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
outputs:
|
||||
major:
|
||||
description: "Major number"
|
||||
value: ${{ jobs.parse.outputs.major }}
|
||||
minor:
|
||||
description: "Minor number"
|
||||
value: ${{ jobs.parse.outputs.minor }}
|
||||
patch:
|
||||
description: "Patch number"
|
||||
value: ${{ jobs.parse.outputs.patch }}
|
||||
build:
|
||||
description: "Build number"
|
||||
value: ${{ jobs.parse.outputs.build }}
|
||||
tag:
|
||||
description: "Tag"
|
||||
value: ${{ jobs.parse.outputs.tag }}
|
||||
releaseChannel:
|
||||
description: "The release channel"
|
||||
value: ${{ jobs.parse.outputs.releaseChannel }}
|
||||
simpleVersion:
|
||||
description: "Simple Version output"
|
||||
value: ${{ jobs.parse.outputs.simpleVersion }}
|
||||
buildVersion:
|
||||
description: "Build Version Output"
|
||||
value: ${{ jobs.parse.outputs.buildVersion }}
|
||||
jobs:
|
||||
parse:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
major: ${{ steps.parseStep.outputs.major }}
|
||||
minor: ${{ steps.parseStep.outputs.minor }}
|
||||
patch: ${{ steps.parseStep.outputs.patch }}
|
||||
build: ${{ steps.parseStep.outputs.build }}
|
||||
tag: ${{ steps.parseStep.outputs.tag }}
|
||||
releaseChannel: ${{ steps.parseStep.outputs.releaseChannel }}
|
||||
simpleVersion: ${{ steps.parseStep.outputs.simpleVersion }}
|
||||
buildVersion: ${{ steps.parseStep.outputs.buildVersion }}
|
||||
steps:
|
||||
- id: parseStep
|
||||
run: |
|
||||
tag="${{ inputs.version }}"
|
||||
tag="${tag#refs/tags/}"
|
||||
|
||||
if [[ "$tag" == *"/"* ]]; then
|
||||
releaseChannel=$(echo "$tag" | cut -d'/' -f1)
|
||||
version=$(echo "$tag" | cut -d'/' -f2)
|
||||
else
|
||||
releaseChannel="beta"
|
||||
version="$tag"
|
||||
fi
|
||||
|
||||
version=$(echo "$tag" | sed 's|.*/||')
|
||||
|
||||
IFS='.' read -r major minor patch build <<< "$version"
|
||||
|
||||
if [ -z "$build" ]; then
|
||||
build="0"
|
||||
fi
|
||||
|
||||
simpleVersion="$major"."$minor"."$patch"."$build"
|
||||
buildVersion="$major"."$minor"."$patch"-build."$build"
|
||||
|
||||
echo "major=$major" >> $GITHUB_OUTPUT
|
||||
echo "minor=$minor" >> $GITHUB_OUTPUT
|
||||
echo "patch=$patch" >> $GITHUB_OUTPUT
|
||||
echo "build=$build" >> $GITHUB_OUTPUT
|
||||
echo "tag=$tag" >> $GITHUB_OUTPUT
|
||||
echo "releaseChannel=$releaseChannel" >> $GITHUB_OUTPUT
|
||||
echo "simpleVersion=$simpleVersion" >> $GITHUB_OUTPUT
|
||||
name: Parse Version Number
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
outputs:
|
||||
major:
|
||||
description: "Major number"
|
||||
value: ${{ jobs.parse.outputs.major }}
|
||||
minor:
|
||||
description: "Minor number"
|
||||
value: ${{ jobs.parse.outputs.minor }}
|
||||
patch:
|
||||
description: "Patch number"
|
||||
value: ${{ jobs.parse.outputs.patch }}
|
||||
build:
|
||||
description: "Build number"
|
||||
value: ${{ jobs.parse.outputs.build }}
|
||||
tag:
|
||||
description: "Tag"
|
||||
value: ${{ jobs.parse.outputs.tag }}
|
||||
releaseChannel:
|
||||
description: "The release channel"
|
||||
value: ${{ jobs.parse.outputs.releaseChannel }}
|
||||
simpleVersion:
|
||||
description: "Simple Version output"
|
||||
value: ${{ jobs.parse.outputs.simpleVersion }}
|
||||
buildVersion:
|
||||
description: "Build Version Output"
|
||||
value: ${{ jobs.parse.outputs.buildVersion }}
|
||||
jobs:
|
||||
parse:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
major: ${{ steps.parseStep.outputs.major }}
|
||||
minor: ${{ steps.parseStep.outputs.minor }}
|
||||
patch: ${{ steps.parseStep.outputs.patch }}
|
||||
build: ${{ steps.parseStep.outputs.build }}
|
||||
tag: ${{ steps.parseStep.outputs.tag }}
|
||||
releaseChannel: ${{ steps.parseStep.outputs.releaseChannel }}
|
||||
simpleVersion: ${{ steps.parseStep.outputs.simpleVersion }}
|
||||
buildVersion: ${{ steps.parseStep.outputs.buildVersion }}
|
||||
steps:
|
||||
- id: parseStep
|
||||
run: |
|
||||
tag="${{ inputs.version }}"
|
||||
tag="${tag#refs/tags/}"
|
||||
|
||||
if [[ "$tag" == *"/"* ]]; then
|
||||
releaseChannel=$(echo "$tag" | cut -d'/' -f1)
|
||||
version=$(echo "$tag" | cut -d'/' -f2)
|
||||
else
|
||||
releaseChannel="beta"
|
||||
version="$tag"
|
||||
fi
|
||||
|
||||
version=$(echo "$tag" | sed 's|.*/||')
|
||||
|
||||
IFS='.' read -r major minor patch build <<< "$version"
|
||||
|
||||
if [ -z "$build" ]; then
|
||||
build="0"
|
||||
fi
|
||||
|
||||
simpleVersion="$major"."$minor"."$patch"."$build"
|
||||
buildVersion="$major"."$minor"."$patch"-build."$build"
|
||||
|
||||
echo "major=$major" >> $GITHUB_OUTPUT
|
||||
echo "minor=$minor" >> $GITHUB_OUTPUT
|
||||
echo "patch=$patch" >> $GITHUB_OUTPUT
|
||||
echo "build=$build" >> $GITHUB_OUTPUT
|
||||
echo "tag=$tag" >> $GITHUB_OUTPUT
|
||||
echo "releaseChannel=$releaseChannel" >> $GITHUB_OUTPUT
|
||||
echo "simpleVersion=$simpleVersion" >> $GITHUB_OUTPUT
|
||||
echo "buildVersion=$buildVersion" >> $GITHUB_OUTPUT
|
@ -1,56 +1,56 @@
|
||||
name: Set Package Version
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
branch:
|
||||
required: true
|
||||
type: string
|
||||
packagePath:
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
SetVersion:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set
|
||||
run: |
|
||||
git pull origin HEAD:${{ inputs.branch }}
|
||||
|
||||
echo "Setting Version to ${{ inputs.version }}"
|
||||
|
||||
git_path=$(pwd)
|
||||
if [ -n "${{ inputs.packagePath }}" ]; then
|
||||
echo "Change Directory to ${{ inputs.packagePath }}"
|
||||
cd ${{ inputs.packagePath }}
|
||||
fi
|
||||
|
||||
npm version --no-git-tag-version ${{ inputs.version }}
|
||||
|
||||
echo "Change Directory back to $git_path"
|
||||
cd $git_path
|
||||
- name: Commit version change
|
||||
run: |
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
echo "No changes in the repository."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
package_name=package.json
|
||||
if [ -n "${{ inputs.packagePath }}" ]; then
|
||||
package_name="${{ inputs.packagePath }}package.json"
|
||||
fi
|
||||
|
||||
git config user.name "${{ vars.GIT_DEPLOY_NAME }}"
|
||||
git config user.email "${{ vars.GIT_DEPLOY_MAIL }}"
|
||||
|
||||
git add $package_name
|
||||
git commit -m "Update package.json version to $TAG_VERSION"
|
||||
|
||||
- name: Push changes back to repository
|
||||
run: |
|
||||
name: Set Package Version
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
branch:
|
||||
required: true
|
||||
type: string
|
||||
packagePath:
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
SetVersion:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set
|
||||
run: |
|
||||
git pull origin HEAD:${{ inputs.branch }}
|
||||
|
||||
echo "Setting Version to ${{ inputs.version }}"
|
||||
|
||||
git_path=$(pwd)
|
||||
if [ -n "${{ inputs.packagePath }}" ]; then
|
||||
echo "Change Directory to ${{ inputs.packagePath }}"
|
||||
cd ${{ inputs.packagePath }}
|
||||
fi
|
||||
|
||||
npm version --no-git-tag-version ${{ inputs.version }}
|
||||
|
||||
echo "Change Directory back to $git_path"
|
||||
cd $git_path
|
||||
- name: Commit version change
|
||||
run: |
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
echo "No changes in the repository."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
package_name=package.json
|
||||
if [ -n "${{ inputs.packagePath }}" ]; then
|
||||
package_name="${{ inputs.packagePath }}package.json"
|
||||
fi
|
||||
|
||||
git config user.name "${{ vars.GIT_DEPLOY_NAME }}"
|
||||
git config user.email "${{ vars.GIT_DEPLOY_MAIL }}"
|
||||
|
||||
git add $package_name
|
||||
git commit -m "Update package.json version to $TAG_VERSION"
|
||||
|
||||
- name: Push changes back to repository
|
||||
run: |
|
||||
git push origin HEAD:${{ inputs.branch }}
|
@ -1,100 +1,100 @@
|
||||
name: Update Release
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag:
|
||||
required: true
|
||||
type: string
|
||||
milestoneName:
|
||||
required: true
|
||||
type: string
|
||||
repo:
|
||||
required: true
|
||||
type: string
|
||||
artifactName:
|
||||
required: false
|
||||
type: string
|
||||
fileName:
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
UpdateRelease:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Load Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.artifactName }}
|
||||
path: ./
|
||||
|
||||
- name: Get Release
|
||||
run: |
|
||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||
OWNER="greyhound"
|
||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||
|
||||
# Fetch Release
|
||||
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")
|
||||
|
||||
# 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
|
||||
|
||||
echo "Found tag '${{ inputs.tag }}' release with ID: $release_id"
|
||||
|
||||
|
||||
|
||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
echo "Milestones: $milestones."
|
||||
|
||||
# Extract the ID of the ${{ inputs.milestoneName }} milestone
|
||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestoneName }}") | .id')
|
||||
|
||||
if [ "$update_milestone_id" != "null" ]; then
|
||||
echo "Milestone named '${{ inputs.milestoneName }}' found with id $update_milestone_id."
|
||||
|
||||
description="https://gitea.greyhound-software.com/$OWNER/${{ inputs.repo }}/milestone/$update_milestone_id"
|
||||
|
||||
release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"body\": \"$description\", \"name\": \"${{ inputs.milestoneName }}\"}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id")
|
||||
fi
|
||||
|
||||
if [ "${{ inputs.artifactName }}" != "null" ]; then
|
||||
artifact_file="./${{ inputs.fileName }}"
|
||||
artifact_name=$(basename "$artifact_file")
|
||||
|
||||
echo "Checking artifact '$artifact_file'"
|
||||
if [ -f "$artifact_file" ]; then
|
||||
echo "Uploading artifact '$artifact_name' to release $release_id..."
|
||||
|
||||
upload_response=$(curl -s -o response.json -w "%{http_code}" -X POST \
|
||||
-H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "name=$artifact_name" \
|
||||
-F "attachment=@$artifact_file" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id/assets")
|
||||
|
||||
http_code=$(echo "$upload_response" | tail -n1) # Last line is the HTTP code
|
||||
if [ "$http_code" -ne 201 ]; then
|
||||
echo "Artifact upload failed with HTTP code: $http_code"
|
||||
echo "Response: $(cat response.json)"
|
||||
exit 1
|
||||
else
|
||||
echo "Artifact uploaded successfully."
|
||||
fi
|
||||
else
|
||||
echo "Artifact file '$artifact_file' not found. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
name: Update Release
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag:
|
||||
required: true
|
||||
type: string
|
||||
milestoneName:
|
||||
required: true
|
||||
type: string
|
||||
repo:
|
||||
required: true
|
||||
type: string
|
||||
artifactName:
|
||||
required: false
|
||||
type: string
|
||||
fileName:
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
UpdateRelease:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Load Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.artifactName }}
|
||||
path: ./
|
||||
|
||||
- name: Get Release
|
||||
run: |
|
||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||
OWNER="greyhound"
|
||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||
|
||||
# Fetch Release
|
||||
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")
|
||||
|
||||
# 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
|
||||
|
||||
echo "Found tag '${{ inputs.tag }}' release with ID: $release_id"
|
||||
|
||||
|
||||
|
||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||
|
||||
echo "Milestones: $milestones."
|
||||
|
||||
# Extract the ID of the ${{ inputs.milestoneName }} milestone
|
||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestoneName }}") | .id')
|
||||
|
||||
if [ "$update_milestone_id" != "null" ]; then
|
||||
echo "Milestone named '${{ inputs.milestoneName }}' found with id $update_milestone_id."
|
||||
|
||||
description="https://gitea.greyhound-software.com/$OWNER/${{ inputs.repo }}/milestone/$update_milestone_id"
|
||||
|
||||
release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"body\": \"$description\", \"name\": \"${{ inputs.milestoneName }}\"}" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id")
|
||||
fi
|
||||
|
||||
if [ "${{ inputs.artifactName }}" != "null" ]; then
|
||||
artifact_file="./${{ inputs.fileName }}"
|
||||
artifact_name=$(basename "$artifact_file")
|
||||
|
||||
echo "Checking artifact '$artifact_file'"
|
||||
if [ -f "$artifact_file" ]; then
|
||||
echo "Uploading artifact '$artifact_name' to release $release_id..."
|
||||
|
||||
upload_response=$(curl -s -o response.json -w "%{http_code}" -X POST \
|
||||
-H "Authorization: token $API_TOKEN" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "name=$artifact_name" \
|
||||
-F "attachment=@$artifact_file" \
|
||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id/assets")
|
||||
|
||||
http_code=$(echo "$upload_response" | tail -n1) # Last line is the HTTP code
|
||||
if [ "$http_code" -ne 201 ]; then
|
||||
echo "Artifact upload failed with HTTP code: $http_code"
|
||||
echo "Response: $(cat response.json)"
|
||||
exit 1
|
||||
else
|
||||
echo "Artifact uploaded successfully."
|
||||
fi
|
||||
else
|
||||
echo "Artifact file '$artifact_file' not found. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
@ -1,50 +1,53 @@
|
||||
name: Upload artifact With Ftp
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
artifactName:
|
||||
required: true
|
||||
type: string
|
||||
fileName:
|
||||
required: true
|
||||
type: string
|
||||
uploadName:
|
||||
required: false
|
||||
type: string
|
||||
ftpPath:
|
||||
required: true
|
||||
type: string
|
||||
txtFileContent:
|
||||
required: false
|
||||
type: string
|
||||
txtFileName:
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
UploadFtp:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Load Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.artifactName }}
|
||||
path: ./
|
||||
- name: Upload
|
||||
run: |
|
||||
upload_name=${{ inputs.fileName }}
|
||||
|
||||
if [ "${{ inputs.uploadName }}" != "" ]; then
|
||||
echo "Renaming file to ${{ inputs.uploadName }}"
|
||||
mv ${{ inputs.fileName }} ${{ inputs.uploadName }}
|
||||
upload_name=${{ inputs.uploadName }}
|
||||
fi
|
||||
|
||||
echo "Uploading $upload_name"
|
||||
curl -T ./$upload_name ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
||||
echo "Uploading finished $upload_name"
|
||||
|
||||
if [ "${{ inputs.txtFileName }}" != "" ]; then
|
||||
echo "Uploading additional Text File ${{ inputs.txtFileName }}"
|
||||
printf "%b" "${{ inputs.txtFileContent }}" > ${{ inputs.txtFileName }}
|
||||
curl -T ./${{ inputs.txtFileName }} ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
||||
fi
|
||||
name: Upload artifact With Ftp
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
artifactName:
|
||||
required: true
|
||||
type: string
|
||||
fileName:
|
||||
required: true
|
||||
type: string
|
||||
uploadName:
|
||||
required: false
|
||||
type: string
|
||||
ftpPath:
|
||||
required: true
|
||||
type: string
|
||||
txtFileContent:
|
||||
required: false
|
||||
type: string
|
||||
txtFileName:
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
UploadFtp:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Load Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.artifactName }}
|
||||
path: ./
|
||||
- name: Upload
|
||||
run: |
|
||||
upload_name=${{ inputs.fileName }}
|
||||
|
||||
if [ "${{ inputs.uploadName }}" != "" ]; then
|
||||
echo "Renaming file to ${{ inputs.uploadName }}"
|
||||
mv ${{ inputs.fileName }} ${{ inputs.uploadName }}
|
||||
upload_name=${{ inputs.uploadName }}
|
||||
fi
|
||||
|
||||
echo "Uploading $upload_name"
|
||||
curl -T ./$upload_name ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
||||
echo "Uploading finished $upload_name"
|
||||
|
||||
echo "TXT Filename is ${{ inputs.txtFileName }}"
|
||||
if [ "${{ inputs.txtFileName }}" != "" ]; then
|
||||
echo "Uploading additional Text File ${{ inputs.txtFileName }}"
|
||||
printf "%b" "${{ inputs.txtFileContent }}" > ${{ inputs.txtFileName }}
|
||||
curl -T ./${{ inputs.txtFileName }} ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
||||
fi
|
||||
|
||||
echo "Ftp Upload done"
|
Loading…
Reference in New Issue
Block a user