Skip to content

Watch Latest Release #19

Watch Latest Release

Watch Latest Release #19

Workflow file for this run

name: Watch Latest Release
on:
workflow_dispatch:
schedule:
- cron: '0 13 * * 1-5'
env:
BASE_URL: https://api.adoptium.net/v3/assets/feature_releases
MAJOR_VERSION: 17
RELEASE_TYPE: ga
ARCHITECTURE: x64
HEAP_SIZE: normal
IMAGE_TYPE: jre
JVM_IMPLEMENTATION: hotspot
OS: linux
JRE_VENDOR: eclipse
permissions:
contents: write
pull-requests: write
# Allow only one concurrent execution, skipping runs queued between the run in-progress and latest queued.
concurrency:
group: watch
jobs:
watch:
name: Watch Latest Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Latest Release
id: get_release
run: |
export "temurin_url=${{ env.BASE_URL }}/${{ env.MAJOR_VERSION }}/${{ env.RELEASE_TYPE }}?architecture=${{ env.ARCHITECTURE }}&heap_size=${{ env.HEAP_SIZE }}&image_type=${{ env.IMAGE_TYPE }}&jvm_impl=${{ env.JVM_IMPLEMENTATION }}&os=${{ env.OS }}&page=0&page_size=1&project=jdk&sort_order=DESC&vendor=${{ env.JRE_VENDOR }}"
release=$(curl -s $temurin_url | jq -r '.[0].version_data.semver')
echo "release=$release" >> $GITHUB_OUTPUT
- name: Check if release is different
id: check_release
run: |
current_version=$(cat .java-version)
echo "CURRENT_VERSION_SEMVER=${current_version}" >> $GITHUB_ENV
echo "CURRENT_VERSION=$(echo $current_version | sed 's/+/_/g')" >> $GITHUB_ENV
if [ "${{ steps.get_release.outputs.release }}" != "${current_version}" ]; then
echo "Release ${{ steps.get_release.outputs.release }} is different from ${current_version}"
echo "NEXT_VERSION_SEMVER=${{ steps.get_release.outputs.release }}" >> $GITHUB_ENV
NEXT_VERSION=$(echo ${{ steps.get_release.outputs.release }} | sed 's/+/_/g')
echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
echo "BRANCH_NAME=feature/v${NEXT_VERSION}" >> $GITHUB_ENV
echo "create_pr=true" >> $GITHUB_OUTPUT
else
echo "Release ${{ steps.get_release.outputs.release }} is the same as ${current_version}"
echo "create_pr=false" >> $GITHUB_OUTPUT
fi
- name: Configure Git User
if: steps.check_release.outputs.create_pr == 'true'
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Create ${{ env.BRANCH_NAME }} branch
if: steps.check_release.outputs.create_pr == 'true'
run: |
git checkout ${{ env.BRANCH_NAME }} 2>/dev/null || git checkout -b ${{ env.BRANCH_NAME }}
git push --force --set-upstream origin ${{ env.BRANCH_NAME }}
- name: Update Version Change from ${{ env.CURRENT_VERSION_SEMVER }} to ${{ env.NEXT_VERSION_SEMVER }} in Files
id: update_version
if: steps.check_release.outputs.create_pr == 'true'
run: |
echo ${{ env.NEXT_VERSION_SEMVER }} > .java-version
sed -i "0,/JDK_VERSION=.*/s//JDK_VERSION=${{ env.NEXT_VERSION }}/" Dockerfile
sed -i "s/${{ env.CURRENT_VERSION }}/${{ env.NEXT_VERSION }}/g" README.md
CHANGES=$(git diff --name-only)
if [ -n "$CHANGES" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo No changes detected in branch ${{ env.BRANCH_NAME }}
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit and Push ${{ env.NEXT_VERSION_SEMVER }}
if: steps.update_version.outputs.changes == 'true'
run: |
git add .java-version README.md Dockerfile
git commit -m "Updated Version to ${{ env.NEXT_VERSION_SEMVER }}"
git push origin ${{ env.BRANCH_NAME }}
- name: Create Pull Request from ${{ env.BRANCH_NAME }} to ${{ github.event.repository.default_branch }}
if: steps.check_release.outputs.create_pr == 'true'
uses: devops-infra/[email protected]
with:
github_token: ${{ github.token }}
source_branch: ${{ env.BRANCH_NAME }}
target_branch: ${{ github.event.repository.default_branch }}
title: Prepare ${{ env.NEXT_VERSION_SEMVER }}
body: |
## Automated update of version
* Prepare **${{ env.NEXT_VERSION_SEMVER }}**
label: automatic
get_diff: true
allow_no_diff: true