Patch #16
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: Patch | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: Patch version (vX.X) | |
required: true | |
jobs: | |
patch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
name: Generate app token | |
with: | |
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }} | |
private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Extract tag versions | |
run: | | |
regex="^v([0-9]+).([0-9]+)$" | |
if [[ ${{ github.event.inputs.releaseVersion }} =~ $regex ]] | |
then | |
echo Release version matches vX.X format | |
else | |
echo ERROR: release version should match the format vX.X | |
exit 1 | |
fi | |
- name: Check if release already exists | |
run: | | |
if git ls-remote --quiet --exit-code origin refs/heads/release/${{ github.event.inputs.releaseVersion }} >/dev/null 2>&1 | |
then | |
echo "Release ${{ github.event.inputs.releaseVersion }} already exists, patch will be perfomed" | |
else | |
echo "Release ${{ github.event.inputs.releaseVersion }} doesn't exist, patch cannot be performed" | |
exit 1 | |
fi | |
- name: Checkout on existing release branch | |
run: | | |
git checkout release/${{ github.event.inputs.releaseVersion }} | |
- name: Extract tag versions | |
run: | | |
lastTag=$(git describe --tags --abbrev=0) | |
regex="v([0-9]+).([0-9]+).([0-9]+)" | |
if [[ $lastTag =~ $regex ]] | |
then | |
major=${BASH_REMATCH[1]} | |
minor=${BASH_REMATCH[2]} | |
patch=${BASH_REMATCH[3]} | |
((++patch)) | |
echo "GITHUB_MAJOR_VERSION=$major" >> $GITHUB_ENV | |
echo "GITHUB_MINOR_VERSION=$minor" >> $GITHUB_ENV | |
echo "GITHUB_PATCH_VERSION=$patch" >> $GITHUB_ENV | |
echo "GITHUB_SHORT_VERSION=$major.$minor.$patch" >> $GITHUB_ENV | |
fi | |
- name: Change Maven version to release version | |
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }} | |
- name: Build with Maven | |
run: mvn --batch-mode -Pjacoco verify | |
- name: Run SonarCloud analysis | |
run: > | |
mvn --batch-mode -DskipTests sonar:sonar | |
-Dsonar.host.url=https://sonarcloud.io | |
-Dsonar.organization=gridsuite | |
-Dsonar.projectKey=gridsuite_spreadsheet-config-server | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Build Docker image | |
run: > | |
mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy | |
-Djib.httpTimeout=60000 | |
-Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${{ env.GITHUB_SHORT_VERSION }} | |
-Djib.to.auth.username=gridsuiteci | |
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Commit and tag release version | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Patched release v${{ env.GITHUB_SHORT_VERSION }}" | |
git tag v${{ env.GITHUB_SHORT_VERSION }} | |
git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} | |
git push origin v${{ env.GITHUB_SHORT_VERSION }} |