Skip to content

Commit 1e90f1d

Browse files
committed
[build] Use ODO binary from nightly builds
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: #4183 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
1 parent 3f586f9 commit 1e90f1d

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

.github/workflows/check-odo.yml

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,59 @@ jobs:
1313
steps:
1414
- name: Check Out Code
1515
uses: actions/checkout@v4
16-
- name: Get latest ODO version
16+
- name: Get latest ODO nightly build version
1717
run: |
1818
echo "REPO_ODO_VERSION=$(cat src/tools.json | jq -r .odo.version)" >> $GITHUB_ENV
19-
LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName,url)
20-
echo "LATEST_TOOL_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName | sed 's|v||')" >> $GITHUB_ENV
21-
echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV
19+
LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName)
20+
latestReleaseTag="$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName)"
21+
echo "LATEST_TOOL_RELEASE_TAG=${latestReleaseTag}" >> $GITHUB_ENV
22+
echo "LATEST_TOOL_RELEASE_VERSION=$(echo ${latestReleaseTag} | sed 's|v||')" >> $GITHUB_ENV
23+
commitId="$(git ls-remote --refs --heads https://github.com/${{ env.TOOL_REPO }} refs/heads/main 2>/dev/null | cut -c1-9 2>/dev/null)"
24+
echo "LATEST_TOOL_COMMIT_ID=${commitId}" >> $GITHUB_ENV
25+
echo "LATEST_TOOL_NIGHTLY_BUILD=${commitId}-nightly" >> $GITHUB_ENV
2226
- name: Find existing PR for ODO version
2327
run: |
24-
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
28+
latestReleaseVersionString="${{ env.LATEST_TOOL_RELEASE_VERSION }} (${{ env.LATEST_TOOL_NIGHTLY_BUILD }})"
29+
echo "LATEST_TOOL_RELEASE_VERSION_STRING=${latestReleaseVersionString}" >> $GITHUB_ENV
30+
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
2531
- name: Update src/tools.json with latest odo version
26-
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
32+
if: ${{ (env.LATEST_TOOL_NIGHTLY_BUILD != '') && (env.LATEST_TOOL_RELEASE_VERSION_STRING != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
2733
run: |
28-
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
34+
jq --indent 4 '.odo.version = "${{env.LATEST_TOOL_RELEASE_VERSION_STRING}}"' src/tools.json \
35+
| jq --indent 4 '.odo.versionRange = "${{env.LATEST_TOOL_RELEASE_VERSION_STRING}}"' \
36+
| jq --indent 4 '.odo.versionRangeLabel = "version == ${{env.LATEST_TOOL_RELEASE_VERSION_STRING}}"' > src/tools.json.new
2937
mv src/tools.json.new src/tools.json
3038
for platform in win32 darwin darwin-arm64 linux linux-arm64; do
31-
old_url=`jq -r .odo.platform.${platform}.url src/tools.json`
32-
new_url=`echo ${old_url} | sed "s|${{ env.REPO_ODO_VERSION }}|${{ env.LATEST_TOOL_RELEASE }}|"`
39+
pltfrm="$platform"
40+
ext=".tar.gz"
41+
exeExt=""
42+
if [[ "$platform" == "win"* ]]; then
43+
pltfrm="windows"
44+
ext=".zip"
45+
exeExt=".exe"
46+
fi
47+
arch="-amd64"
48+
if [[ $platform == *"-a"* ]]; then
49+
arch="" # already in platform string
50+
fi
51+
old_url=`jq -r ".odo.platform[\"${platform}\"].url" src/tools.json`
52+
new_url="https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-nightly-builds/odo-${pltfrm}${arch}${ext}"
3353
checksum=`curl -s ${new_url}.sha256`
34-
jq --indent 4 ".odo.platform.${platform}.url = \"${new_url}\"" src/tools.json | jq --indent 4 ".odo.platform.${platform}.sha256sum = \"${checksum}\"" > src/tools.json.new
54+
dlFileName="odo-${pltfrm}${arch}${ext}"
55+
cmdFileName="odo${exeExt}"
56+
jq --indent 4 ".odo.platform[\"${platform}\"].url = \"${new_url}\"" src/tools.json \
57+
| jq --indent 4 ".odo.platform[\"${platform}\"].sha256sum = \"${checksum}\"" \
58+
| jq --indent 4 ".odo.platform[\"${platform}\"].dlFileName = \"${dlFileName}\"" \
59+
| jq --indent 4 ".odo.platform[\"${platform}\"].cmdFileName = \"${cmdFileName}\"" > src/tools.json.new > src/tools.json.new
3560
mv src/tools.json.new src/tools.json
3661
done
3762
- name: Create pull request
38-
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
63+
if: ${{ (env.LATEST_TOOL_RELEASE_VERSION_STRING != '') && (env.LATEST_TOOL_RELEASE_VERSION_STRING != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
3964
run: |
4065
git config --global user.email "openshifttools-bot@users.noreply.github.com"
4166
git config --global user.name "openshifttools-bot"
42-
git checkout -b "odo-${{ env.LATEST_TOOL_RELEASE }}"
43-
git commit -am "Update odo to ${{ env.LATEST_TOOL_RELEASE }}"
44-
git push origin "odo-${{ env.LATEST_TOOL_RELEASE }}"
45-
gh pr create --title "Update odo to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}"
67+
git checkout -b "odo-${{ env.LATEST_TOOL_NIGHTLY_BUILD }}"
68+
git commit -am "Update ODO CLI to ${{ env.LATEST_TOOL_RELEASE_VERSION_STRING }}"
69+
git push -f origin "odo-${{ env.LATEST_TOOL_NIGHTLY_BUILD }}"
70+
gh pr create --title "Update ODO CLI to ${{ env.LATEST_TOOL_RELEASE_VERSION_STRING }}" \
71+
--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 commit comments

Comments
 (0)