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
name: Check for version increments and apply them if necessary | ||
on: | ||
workflow_call: | ||
inputs: | ||
botName: | ||
description: The name of the bot that adds the necessary version increment changes | ||
type: string | ||
required: true | ||
botMail: | ||
description: The name of the bot that adds the necessary version increment changes | ||
type: string | ||
required: true | ||
excludedProjects: | ||
description: The comma-separated list of projects that should not be skipped (e.g. products or repositories). Can speed-up the check | ||
type: string | ||
required: false | ||
default: '' | ||
secrets: | ||
githubBotPAT: | ||
description: The personal access token (with scope 'public_repo') of the bot to push a required change to a PR branch in a fork. | ||
required: false | ||
#TODO: revise inputs once done | ||
permissions: read-all | ||
#permissions: | ||
# contents: read | ||
# issues: write | ||
jobs: | ||
versions-check-and-increment: | ||
name: Check and increment service versions | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dump GitHub context | ||
run: echo '${{ toJSON(github) }}' | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
#with: | ||
#ref: '${{ github.event.pull_request.head.sha }}' | ||
#persist-credentials: false #Opt out from persisting the default Github-token authentication in order to enable use of the bot's PAT when pushing below | ||
# token: ${{ secrets.githubBotPAT }} TODO: alternativly use this and and just add the fork without basic auth below. | ||
- name: Set up Java | ||
uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Check and increment versions | ||
uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # master | ||
with: | ||
attempt_delay: 200 | ||
attempt_limit: 10 | ||
command: | | ||
echo 'Hello World'>someFile.txt | ||
echo 'Hello World 2'>someFile2.txt | ||
ls | ||
# mvn clean verify -B -fae -T 1C | ||
# org.eclipse.tycho:tycho-versions-plugin:bump-versions | ||
# -DskipTests | ||
# -Dcompare-version-with-baselines.skip=false | ||
#TODO: exclude products, p2-repos etc: | ||
# https://stackoverflow.com/questions/13266470/how-do-i-exclude-certain-modules-from-a-maven-build-using-the-commandline | ||
# Do something like -pl '!excludedProjects.replace(',','!,')' | ||
# Or create a list of all eclipse-plugin and eclipse-feature projects and use it here as input for PL?! Could be done with java-script?! | ||
# Or check if one can just compute the build-qualifier and then run the baseline plugin?! | ||
- name: Commit and push version increments, if any | ||
run: | | ||
if [[ $(git status --ignore-submodules --porcelain) != '' ]]; then | ||
# Workspace is not clean, i.e. some version were changed | ||
# Read pom project parent version or project version as development stream version | ||
sudo apt-get install -qq -y libxml2-utils | ||
pomVersion=$(xmllint --xpath "(/*[local-name()='project']/*[local-name()='parent'] | /*[local-name()='project'])/*[local-name()='version']/text()" pom.xml) | ||
streamVersion=$(echo "${pomVersion}" | cut -d '.' -f1-2) | ||
git config --global user.email '${{ inputs.botMail }}' | ||
git config --global user.name '${{ inputs.botName }}' | ||
git add --all | ||
git status | ||
git commit -m "Bump version(s) for ${streamVersion} stream" | ||
git format-patch -1 HEAD --no-stat --output 'version_increments.patch' | ||
# --no-prefix | ||
else | ||
echo 'No versions have to be incremented' | ||
fi | ||
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | ||
with: | ||
name: versions-git-patch | ||
path: version_increments.patch |