@@ -2,44 +2,115 @@ name: check-odo
2
2
3
3
on :
4
4
schedule :
5
- - cron : " 0 8 * * *"
5
+ - cron : " * 8 * * *"
6
6
workflow_dispatch :
7
+ env :
8
+ TOOL_REPO : redhat-developer/odo
9
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7
10
jobs :
8
- check-odo-repo :
11
+ check-odo :
9
12
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 != '' || github.event_name != 'schedule' }}
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
+
57
+ check-nightly-build :
58
+ runs-on : ubuntu-latest
59
+ outputs :
60
+ nightly-build-exists : ${{ steps.check-nightly-build-exists.outputs.nightly-build-exists }}
61
+ needs : [check-odo, check-pr]
62
+ if : ${{ needs.check-pr.outputs.pr-exists == 0 || github.event_name != 'schedule' }}
63
+ steps :
64
+ - name : Check if a Nightly Build exists for the last commit id
65
+ id : check-nightly-build-exists
66
+ 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
67
+
68
+ update-odo :
69
+ runs-on : ubuntu-latest
70
+ needs : [check-odo, check-pr, check-nightly-build]
71
+ if : ${{ needs.check-odo.outputs.last-commit-id != '' && needs.check-pr.outputs.pr-exists == 0 && needs.check-nightly-build.outputs.nightly-build-exists != 0 }}
13
72
steps :
14
73
- name : Check Out Code
15
74
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
25
75
- 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) }}
27
76
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
77
+ jq --indent 4 '.odo.description = "ODO CLI tool"' src/tools.json \
78
+ | jq --indent 4 '.odo.vendor = "Red Hat Developer"' \
79
+ | jq --indent 4 '.odo.name = "odo"' \
80
+ | jq --indent 4 '.odo.version = "${{ needs.check-odo.outputs.last-release-version }}"' \
81
+ | jq --indent 4 '.odo.versionRange = "^${{ needs.check-odo.outputs.last-release-version }}"' \
82
+ | jq --indent 4 '.odo.versionRangeLabel = "version >= ${{ needs.check-odo.outputs.last-release-version }}"' > src/tools.json.new
29
83
mv src/tools.json.new src/tools.json
30
84
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 }}|"`
85
+ pltfrm="$platform"
86
+ ext=".tar.gz"
87
+ exeExt=""
88
+ if [[ "$platform" == "win"* ]]; then
89
+ pltfrm="windows"
90
+ ext=".zip"
91
+ exeExt=".exe"
92
+ fi
93
+ arch="-amd64"
94
+ if [[ $platform == *"-a"* ]]; then
95
+ arch="" # already in platform string
96
+ fi
97
+ old_url=`jq -r ".odo.platform[\"${platform}\"].url" src/tools.json`
98
+ 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}"
33
99
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
100
+ dlFileName="odo-${pltfrm}${arch}${ext}"
101
+ cmdFileName="odo-${pltfrm}${arch}-${{ needs.check-odo.outputs.last-commit-id }}${exeExt}"
102
+ jq --indent 4 ".odo.platform[\"${platform}\"].url = \"${new_url}\"" src/tools.json \
103
+ | jq --indent 4 ".odo.platform[\"${platform}\"].sha256sum = \"${checksum}\"" \
104
+ | jq --indent 4 ".odo.platform[\"${platform}\"].dlFileName = \"${dlFileName}\"" \
105
+ | jq --indent 4 ".odo.platform[\"${platform}\"].cmdFileName = \"${cmdFileName}\"" > src/tools.json.new > src/tools.json.new
35
106
mv src/tools.json.new src/tools.json
36
107
done
37
108
- name : Create pull request
38
- if : ${{ (env.LATEST_TOOL_RELEASE != '') && (env.LATEST_TOOL_RELEASE != env.REPO_ODO_VERSION) && (env.PR_EXISTS == 0) }}
39
109
run : |
40
110
git config --global user.email "[email protected] "
41
111
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 }}"
112
+ git checkout -b "bump-odo-${{ needs.check-odo.outputs.last-release-version }}-${{ needs.check-odo.outputs.last-commit-id }}"
113
+ git commit -am "Update ODO CLI to ${{ needs.check-odo.outputs.nightly-build-version }}"
114
+ git push -f origin "bump-odo-${{ needs.check-odo.outputs.last-release-version }}-${{ needs.check-odo.outputs.last-commit-id }}"
115
+ gh pr create --title "Update ODO CLI to ${{ needs.check-odo.outputs.nightly-build-version }}" \
116
+ --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