Skip to content

Commit c96e2cc

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 c96e2cc

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

.github/workflows/check-odo.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,57 @@ 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+
echo PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state open --search "update odo cli to ${{env.LATEST_TOOL_RELEASE_VERSION}} (${{env.LATEST_TOOL_NIGHTLY_BUILD}}) in:title" --json url | jq length) >> $GITHUB_ENV
2529
- 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) }}
30+
if: ${{ (env.LATEST_TOOL_NIGHTLY_BUILD != '') && (env.LATEST_TOOL_NIGHTLY_BUILD != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
2731
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
32+
jq --indent 4 '.odo.version = "${{env.LATEST_TOOL_RELEASE_VERSION}} (${{env.LATEST_TOOL_NIGHTLY_BUILD}})"' src/tools.json \
33+
| jq --indent 4 '.odo.versionRange = "${{env.LATEST_TOOL_RELEASE_VERSION}} (${{env.LATEST_TOOL_NIGHTLY_BUILD}})"' \
34+
| jq --indent 4 '.odo.versionRangeLabel = "version == ${{env.LATEST_TOOL_RELEASE_VERSION}} (${{env.LATEST_TOOL_NIGHTLY_BUILD}})"' > src/tools.json.new
2935
mv src/tools.json.new src/tools.json
3036
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 }}|"`
37+
pltfrm="$platform"
38+
ext=".tar.gz"
39+
exeExt=""
40+
if [[ "$platform" == "win"* ]]; then
41+
pltfrm="windows"
42+
ext=".zip"
43+
exeExt=".exe"
44+
fi
45+
arch="-amd64"
46+
if [[ $platform == *"-a"* ]]; then
47+
arch="" # already in platform string
48+
fi
49+
old_url=`jq -r ".odo.platform[\"${platform}\"].url" src/tools.json`
50+
new_url="https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-nightly-builds/odo-${pltfrm}${arch}${ext}"
3351
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
52+
dlFileName="odo-${pltfrm}${arch}${ext}"
53+
cmdFileName="odo${exeExt}"
54+
jq --indent 4 ".odo.platform[\"${platform}\"].url = \"${new_url}\"" src/tools.json \
55+
| jq --indent 4 ".odo.platform[\"${platform}\"].sha256sum = \"${checksum}\"" \
56+
| jq --indent 4 ".odo.platform[\"${platform}\"].dlFileName = \"${dlFileName}\"" \
57+
| jq --indent 4 ".odo.platform[\"${platform}\"].cmdFileName = \"${cmdFileName}\"" > src/tools.json.new > src/tools.json.new
3558
mv src/tools.json.new src/tools.json
3659
done
3760
- name: Create pull request
38-
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
61+
if: ${{ (env.LATEST_TOOL_NIGHTLY_BUILD != '') && (env.LATEST_TOOL_NIGHTLY_BUILD != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
3962
run: |
4063
git config --global user.email "openshifttools-bot@users.noreply.github.com"
4164
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 }}"
65+
git checkout -b "odo-${{ env.LATEST_TOOL_NIGHTLY_BUILD }}"
66+
git commit -am "Update ODO CLI to ${{env.LATEST_TOOL_RELEASE_VERSION}} (${{env.LATEST_TOOL_NIGHTLY_BUILD}})"
67+
git push -f origin "odo-${{ env.LATEST_TOOL_NIGHTLY_BUILD }}"
68+
gh pr create --title "Update ODO CLI to ${{env.LATEST_TOOL_RELEASE_VERSION}} (${{env.LATEST_TOOL_NIGHTLY_BUILD}})" \
69+
--body "See commit history since version ${{env.LATEST_TOOL_RELEASE_VERSION}} at: https://github.com/redhat-developer/odo/compare/${{env.LATEST_TOOL_RELEASE_TAG}}...${{ env.LATEST_TOOL_COMMIT_ID }}"

0 commit comments

Comments
 (0)