Skip to content

Commit 9035c72

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 <[email protected]>
1 parent f209e6c commit 9035c72

File tree

1 file changed

+92
-23
lines changed

1 file changed

+92
-23
lines changed

.github/workflows/check-odo.yml

+92-23
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,111 @@ on:
44
schedule:
55
- cron: "0 8 * * *"
66
workflow_dispatch:
7+
env:
8+
TOOL_REPO: redhat-developer/odo
9+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
710
jobs:
8-
check-odo-repo:
11+
check-odo:
912
runs-on: ubuntu-latest
10-
env:
11-
TOOL_REPO: redhat-developer/odo
12-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
outputs:
14+
last-commit-id: ${{ steps.repo-last-commit-info.outputs.repo-last-commit-id }}
15+
last-release-tag: ${{ steps.repo-last-commit-info.outputs.repo-last-release-tag }}
16+
last-release-version: ${{ steps.repo-last-commit-info.outputs.repo-last-release-version }}
17+
nightly-build-version: ${{ steps.repo-last-commit-info.outputs.repo-nightly-build-version }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
repository: '${{ env.TOOL_REPO }}'
22+
fetch-depth: 2
23+
fetch-tags: false
24+
path: redhat-developer-odo-repository
25+
- name: Get Last Commit Info
26+
id: repo-last-commit-info
27+
run: |
28+
pushd redhat-developer-odo-repository
29+
30+
# Last Commit ID (short or abbreviated to 9 characters version)
31+
lastCommitId="$(git describe --no-match --always --abbrev=9 --dirty --broken 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
32+
echo "repo-last-commit-id=$lastCommitId" >> $GITHUB_OUTPUT
33+
34+
# Last Release Tag and Version
35+
lastReleaseTag=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName | jq -r .tagName)
36+
lastReleaseVersion="$(echo $lastReleaseTag | sed 's|v||')"
37+
echo "repo-last-release-tag=$lastReleaseTag" >> $GITHUB_OUTPUT
38+
echo "repo-last-release-version=$lastReleaseVersion" >> $GITHUB_OUTPUT
39+
40+
# Nightly Build Version
41+
echo "repo-nightly-build-version=$lastReleaseVersion (${lastCommitId}-nightly)" >> $GITHUB_OUTPUT
42+
43+
popd
44+
45+
check-pr:
46+
runs-on: ubuntu-latest
47+
outputs:
48+
pr-exists: ${{ steps.check-pr-exists.outputs.pr-exists }}
49+
needs: check-odo
50+
if: ${{ needs.check-odo.outputs.last-commit-id != '' }}
51+
steps:
52+
- name: Check if the update PR already exists
53+
id: check-pr-exists
54+
run: echo pr-exists=$(gh pr --repo ${{ github.repository }} list --state all --search "update odo cli to ${{ needs.check-odo.outputs.last-release-version }} (${{ needs.check-odo.outputs.last-commit-id }}-nightly) in:title" --json url | jq length) >> $GITHUB_OUTPUT
55+
56+
check-nightly-build:
57+
runs-on: ubuntu-latest
58+
outputs:
59+
nightly-build-exists: ${{ steps.check-nightly-build-exists.outputs.nightly-build-exists }}
60+
needs: [check-odo, check-pr]
61+
if: ${{ needs.check-odo.outputs.last-commit-id != '' && needs.check-pr.outputs.pr-exists == 0 }}
62+
steps:
63+
- name: Check if a Nightly Build exists for the last commit id
64+
id: check-nightly-build-exists
65+
run: echo nightly-build-exists=`curl -s "https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-nightly-builds/odo-linux-arm64-${{ needs.check-odo.outputs.last-commit-id }}.tar.gz.sha256" | grep -E "^[A-Za-z0-9]+$" | wc -w` >> $GITHUB_OUTPUT
66+
67+
update-odo:
68+
runs-on: ubuntu-latest
69+
needs: [check-odo, check-pr, check-nightly-build]
70+
if: ${{ needs.check-odo.outputs.last-commit-id != '' && needs.check-pr.outputs.pr-exists == 0 && needs.check-nightly-build.outputs.nightly-build-exists != 0 }}
1371
steps:
1472
- name: Check Out Code
1573
uses: actions/checkout@v4
16-
- name: Get latest ODO version
17-
run: |
18-
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
22-
- name: Find existing PR for ODO version
23-
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
2574
- 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) }}
2775
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
76+
jq --indent 4 '.odo.description = "ODO CLI tool"' src/tools.json \
77+
| jq --indent 4 '.odo.vendor = "Red Hat Developer"' \
78+
| jq --indent 4 '.odo.name = "odo"' \
79+
| jq --indent 4 '.odo.version = "${{ needs.check-odo.outputs.last-release-version }}"' \
80+
| jq --indent 4 '.odo.versionRange = "^${{ needs.check-odo.outputs.last-release-version }}"' \
81+
| jq --indent 4 '.odo.versionRangeLabel = "version >= ${{ needs.check-odo.outputs.last-release-version }}"' > src/tools.json.new
2982
mv src/tools.json.new src/tools.json
3083
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 }}|"`
84+
pltfrm="$platform"
85+
ext=".tar.gz"
86+
exeExt=""
87+
if [[ "$platform" == "win"* ]]; then
88+
pltfrm="windows"
89+
ext=".zip"
90+
exeExt=".exe"
91+
fi
92+
arch="-amd64"
93+
if [[ $platform == *"-a"* ]]; then
94+
arch="" # already in platform string
95+
fi
96+
new_url="https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-nightly-builds/odo-${pltfrm}${arch}-${{ needs.check-odo.outputs.last-commit-id }}${ext}"
3397
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
98+
dlFileName="odo-${pltfrm}${arch}${ext}"
99+
cmdFileName="odo-${pltfrm}${arch}-${{ needs.check-odo.outputs.last-commit-id }}${exeExt}"
100+
jq --indent 4 ".odo.platform[\"${platform}\"].url = \"${new_url}\"" src/tools.json \
101+
| jq --indent 4 ".odo.platform[\"${platform}\"].sha256sum = \"${checksum}\"" \
102+
| jq --indent 4 ".odo.platform[\"${platform}\"].dlFileName = \"${dlFileName}\"" \
103+
| jq --indent 4 ".odo.platform[\"${platform}\"].cmdFileName = \"${cmdFileName}\"" > src/tools.json.new > src/tools.json.new
35104
mv src/tools.json.new src/tools.json
36105
done
37106
- name: Create pull request
38-
if: ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
39107
run: |
40108
git config --global user.email "[email protected]"
41109
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 }}"
110+
git checkout -b "bump-odo-${{ needs.check-odo.outputs.last-release-version }}-${{ needs.check-odo.outputs.last-commit-id }}"
111+
git commit -am "Update ODO CLI to ${{ needs.check-odo.outputs.nightly-build-version }}"
112+
git push -f origin "bump-odo-${{ needs.check-odo.outputs.last-release-version }}-${{ needs.check-odo.outputs.last-commit-id }}"
113+
gh pr create --title "Update ODO CLI to ${{ needs.check-odo.outputs.nightly-build-version }}" \
114+
--body "See the commit history between release ${{needs.check-odo.outputs.last-release-version}} and the latest nightly version ${{ needs.check-odo.outputs.nightly-build-version }} at: https://github.com/redhat-developer/odo/compare/${{needs.check-odo.outputs.last-release-tag}}...${{ needs.check-odo.outputs.last-commit-id }}"

0 commit comments

Comments
 (0)