-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Maven fetch and autobump latest versions feature
- Loading branch information
Showing
2 changed files
with
70 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ on: | |
schedule: | ||
- cron: '0 22 * * 5' # Every Friday at 10 PM UTC | ||
workflow_dispatch: | ||
env: | ||
jdk_list: 8,11,17,21 | ||
mvn_list: 3.0,3.2,3.3,3.5,3.6,3.8,3.9,4.0 | ||
|
||
jobs: | ||
check-available-zulu-jdks: | ||
|
@@ -20,8 +23,35 @@ jobs: | |
echo " - JDK ${paddingspace}${major_jdk_version}: $(echo ${latestversion} | sed 's/,/./g')" >> $GITHUB_STEP_SUMMARY | ||
done | ||
echo "Done" | ||
env: | ||
jdk_list: 8,11,17,21 | ||
check-autobump-available-maven: | ||
name: Check and autobump Maven versions | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.SWF_TOKEN }} | ||
- name: Autobump latest maven versions | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "eXo Software Factory" | ||
echo "Fetching latest versions of Maven (${mvn_list}):" | ||
echo "### Maven Versions List:" >> $GITHUB_STEP_SUMMARY | ||
for major_mvn_version in ${mvn_list//,/ }; do | ||
latestversion=$(curl -fsSL -X GET "https://archive.apache.org/dist/maven/maven-${major_mvn_version%%.*}/" | grep -o 'href=".*">' | sed -e "s/href=\"//g" | sed -e 's/">//g' | tail -n +2 | tr -d '/' | grep -P "^${major_mvn_version}" | tail -1) | ||
if [ -z "${latestversion}" ]; then | ||
echo "Error: Cannot find latest version for Maven ${major_mvn_version}! Abort!" | ||
exit 1 | ||
fi | ||
echo " - Maven ${major_mvn_version}: ${latestversion}" | ||
echo " - Maven ${major_mvn_version}: ${latestversion}" >> $GITHUB_STEP_SUMMARY | ||
grep -irl "ENV MAVEN_VERSION=${major_mvn_version}" --include=Dockerfile | xargs -r sed -Ei "s/^ENV MAVEN_VERSION=.*/ENV MAVEN_VERSION=${latestversion}/" | ||
git add -u | ||
git diff-index --quiet HEAD || git commit -m "Autobump maven ${major_mvn_version} to ${latestversion}" | ||
done | ||
echo "Done" | ||
git push origin HEAD | ||
build-base-images: | ||
name: "Build Base Images" | ||
|
@@ -98,7 +128,7 @@ jobs: | |
|
||
build-maven-images: | ||
name: "Build Maven Images" | ||
needs: build-jdk-images | ||
needs: [check-autobump-available-maven, build-jdk-images] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -244,16 +274,16 @@ jobs: | |
DOCKER_PRIVATE_KEY: ${{ secrets.DOCKER_PRIVATE_KEY }} | ||
DOCKER_PRIVATE_KEY_PASSPHRASE: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }} | ||
|
||
update-zulu-jdks-readme: | ||
name: "Update Readme file jdk section" | ||
update-zulu-jdks-and-maven-readme: | ||
name: "Update Readme file jdk & Maven section" | ||
needs: build-maven-images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.SWF_TOKEN }} | ||
- name: Check latest jdk versions | ||
- name: Check latest jdk & maven versions | ||
run: | | ||
if ! grep -q '<!-- GHASTART -->' README.md; then | ||
echo "Error: Cannot find <!-- GHASTART --> md comment in Readme.md file! Abort" | ||
|
@@ -272,6 +302,14 @@ jobs: | |
fi | ||
export JDK${major_jdk_version}_VERSION=$(echo ${latestversion} | sed 's/,/./g') | ||
done | ||
for major_mvn_version in ${mvn_list//,/ }; do | ||
latestversion=$(curl -fsSL -X GET "https://archive.apache.org/dist/maven/maven-${major_mvn_version%%.*}/" | grep -o 'href=".*">' | sed -e "s/href=\"//g" | sed -e 's/">//g' | tail -n +2 | tr -d '/' | grep -P "^${major_mvn_version}" | tail -1) | ||
if [ -z "${latestversion}" ]; then | ||
echo "Error: Cannot find latest version for Maven ${major_mvn_version}! Abort!" | ||
exit 1 | ||
fi | ||
export MVN${major_mvn_version//./}_VERSION=$(echo ${latestversion} | sed 's/,/./g') | ||
done | ||
perl -pe 's/\$\{([^}]+)\}/$ENV{$1} || ""/ge' .github/table-template.md | column -t -s '|' -o '|' > /tmp/mdtable | ||
sed '/<!-- GHASTART -->/q' README.md > /tmp/newreadme | ||
cat /tmp/mdtable >> /tmp/newreadme | ||
|
@@ -281,7 +319,5 @@ jobs: | |
git config --global user.email "[email protected]" | ||
git config --global user.name "eXo Software Factory" | ||
git add README.md | ||
git diff-index --quiet HEAD || git commit -m "Automated JDK versions README update" | ||
git diff-index --quiet HEAD || git commit -m "Automated JDK & Maven versions README update" | ||
git push origin HEAD | ||
env: | ||
jdk_list: 8,11,17,21 |