Skip to content

chore: integrate automated release in github workflows (#2) #1

chore: integrate automated release in github workflows (#2)

chore: integrate automated release in github workflows (#2) #1

Workflow file for this run

name: Release
on:
push:
tags:
- 'v[0-9]*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Checkout sources
uses: actions/checkout@v1
- name: Remove original tag
run: |
git tag -d ${{ github.ref_name }}
git push origin :refs/tags/${{ github.ref_name }}
- name: Extract tag versions
run: |
regex="v([0-9]+).([0-9]+).([0-9]+)"
if [[ $1 =~ $regex ]]
then
echo "GITHUB_MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
echo "GITHUB_MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
echo "GITHUB_PATCH_VERSION=${BASH_REMATCH[3]}" >> $GITHUB_ENV
fi
- name: Change Maven version to release version
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.${{ env.GITHUB_PATCH_VERSION }}
- name: Commit and tag release version
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
branch: release-${{ github.ref_name }}
create_branch: true
commit_message: Prepare release ${{ github.ref_name }}
tagging_message: ${{ github.ref_name }}
- 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:${GITHUB_REF_NAME#v}
-Djib.to.auth.username=gridsuiteci
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }}
- name: Increment minor version
run: |
minor=${{ env.GITHUB_MINOR_VERSION }}
((minor++))
echo "GITHUB_MINOR_VERSION=${minor}" >> $GITHUB_ENV
- name: Change Maven version to next version
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.${{ env.GITHUB_PATCH_VERSION }}-SNAPSHOT
- name: Commit next version
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
branch: release-${{ github.ref_name }}
commit_message: Prepare next release v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.${{ env.GITHUB_PATCH_VERSION }}
skip_fetch: true
skip_checkout: true
- name: Merge automatically into main branch
uses: devmasx/merge-branch@v1.4.0
with:
type: now
from_branch: release-${{ github.ref_name }}
target_branch: main
message: Automatic merge after release ${{ github.ref_name }}
github_token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Delete merged branch
uses: dawidd6/action-delete-branch@v3.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: release-${{ github.ref_name }}