Skip to content

Commit

Permalink
[build] Use ODO binary from nightly builds
Browse files Browse the repository at this point in the history
Since the [ODO project](https://github.com/redhat-developer/odo) has stoped producing new releases
for ODO binary, the [nightly builds](https://odo.dev/docs/overview/installation/#nightly-builds)
became the source of most recent and up-to-date ODO binary version.

Fixes: redhat-developer#4183

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
  • Loading branch information
vrubezhny committed Jun 10, 2024
1 parent 3f586f9 commit 1e90f1d
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions .github/workflows/check-odo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,59 @@ jobs:
steps:
- name: Check Out Code
uses: actions/checkout@v4
- name: Get latest ODO version
- name: Get latest ODO nightly build version
run: |
echo "REPO_ODO_VERSION=$(cat src/tools.json | jq -r .odo.version)" >> $GITHUB_ENV
LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName,url)
echo "LATEST_TOOL_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName | sed 's|v||')" >> $GITHUB_ENV
echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV
LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName)
latestReleaseTag="$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName)"
echo "LATEST_TOOL_RELEASE_TAG=${latestReleaseTag}" >> $GITHUB_ENV
echo "LATEST_TOOL_RELEASE_VERSION=$(echo ${latestReleaseTag} | sed 's|v||')" >> $GITHUB_ENV
commitId="$(git ls-remote --refs --heads https://github.com/${{ env.TOOL_REPO }} refs/heads/main 2>/dev/null | cut -c1-9 2>/dev/null)"
echo "LATEST_TOOL_COMMIT_ID=${commitId}" >> $GITHUB_ENV
echo "LATEST_TOOL_NIGHTLY_BUILD=${commitId}-nightly" >> $GITHUB_ENV
- name: Find existing PR for ODO version
run: |
echo PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state all --search "update odo ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length) >> $GITHUB_ENV
latestReleaseVersionString="${{ env.LATEST_TOOL_RELEASE_VERSION }} (${{ env.LATEST_TOOL_NIGHTLY_BUILD }})"
echo "LATEST_TOOL_RELEASE_VERSION_STRING=${latestReleaseVersionString}" >> $GITHUB_ENV
echo PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state open --search "update odo cli to ${latestReleaseVersionString} in:title" --json url | jq length) >> $GITHUB_ENV
- name: Update src/tools.json with latest odo version
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
if: ${{ (env.LATEST_TOOL_NIGHTLY_BUILD != '') && (env.LATEST_TOOL_RELEASE_VERSION_STRING != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
run: |
jq --indent 4 '.odo.version = "${{ env.LATEST_TOOL_RELEASE }}"' src/tools.json | jq --indent 4 '.odo.versionRange = "^${{ env.LATEST_TOOL_RELEASE }}"' | jq --indent 4 '.odo.versionRangeLabel = "version >= ${{ env.LATEST_TOOL_RELEASE }}"' > src/tools.json.new
jq --indent 4 '.odo.version = "${{env.LATEST_TOOL_RELEASE_VERSION_STRING}}"' src/tools.json \
| jq --indent 4 '.odo.versionRange = "${{env.LATEST_TOOL_RELEASE_VERSION_STRING}}"' \
| jq --indent 4 '.odo.versionRangeLabel = "version == ${{env.LATEST_TOOL_RELEASE_VERSION_STRING}}"' > src/tools.json.new
mv src/tools.json.new src/tools.json
for platform in win32 darwin darwin-arm64 linux linux-arm64; do
old_url=`jq -r .odo.platform.${platform}.url src/tools.json`
new_url=`echo ${old_url} | sed "s|${{ env.REPO_ODO_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"`
pltfrm="$platform"
ext=".tar.gz"
exeExt=""
if [[ "$platform" == "win"* ]]; then
pltfrm="windows"
ext=".zip"
exeExt=".exe"
fi
arch="-amd64"
if [[ $platform == *"-a"* ]]; then
arch="" # already in platform string
fi
old_url=`jq -r ".odo.platform[\"${platform}\"].url" src/tools.json`
new_url="https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-nightly-builds/odo-${pltfrm}${arch}${ext}"
checksum=`curl -s ${new_url}.sha256`
jq --indent 4 ".odo.platform.${platform}.url = \"${new_url}\"" src/tools.json | jq --indent 4 ".odo.platform.${platform}.sha256sum = \"${checksum}\"" > src/tools.json.new
dlFileName="odo-${pltfrm}${arch}${ext}"
cmdFileName="odo${exeExt}"
jq --indent 4 ".odo.platform[\"${platform}\"].url = \"${new_url}\"" src/tools.json \
| jq --indent 4 ".odo.platform[\"${platform}\"].sha256sum = \"${checksum}\"" \
| jq --indent 4 ".odo.platform[\"${platform}\"].dlFileName = \"${dlFileName}\"" \
| jq --indent 4 ".odo.platform[\"${platform}\"].cmdFileName = \"${cmdFileName}\"" > src/tools.json.new > src/tools.json.new
mv src/tools.json.new src/tools.json
done
- name: Create pull request
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
if: ${{ (env.LATEST_TOOL_RELEASE_VERSION_STRING != '') && (env.LATEST_TOOL_RELEASE_VERSION_STRING != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
run: |
git config --global user.email "openshifttools-bot@users.noreply.github.com"
git config --global user.name "openshifttools-bot"
git checkout -b "odo-${{ env.LATEST_TOOL_RELEASE }}"
git commit -am "Update odo to ${{ env.LATEST_TOOL_RELEASE }}"
git push origin "odo-${{ env.LATEST_TOOL_RELEASE }}"
gh pr create --title "Update odo to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}"
git checkout -b "odo-${{ env.LATEST_TOOL_NIGHTLY_BUILD }}"
git commit -am "Update ODO CLI to ${{ env.LATEST_TOOL_RELEASE_VERSION_STRING }}"
git push -f origin "odo-${{ env.LATEST_TOOL_NIGHTLY_BUILD }}"
gh pr create --title "Update ODO CLI to ${{ env.LATEST_TOOL_RELEASE_VERSION_STRING }}" \
--body "See commit history since version ${{ env.LATEST_TOOL_RELEASE_VERSION }} to ${{ env.LATEST_TOOL_RELEASE_VERSION_STRING }} at: https://github.com/redhat-developer/odo/compare/${{env.LATEST_TOOL_RELEASE_TAG}}...${{ env.LATEST_TOOL_COMMIT_ID }}"

0 comments on commit 1e90f1d

Please sign in to comment.