From bc6ed1792a5531894c1d144e0f40a3b3472558bd Mon Sep 17 00:00:00 2001 From: Alessadro Parisi Date: Fri, 7 Jun 2024 23:50:40 +0200 Subject: [PATCH] :construction_worker: Add release action --- .github/workflows/release.yml | 86 +++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f2e0496f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: 'Release new versions' +on: + workflow_run: + workflows: [Build rewrite] + types: + - completed + +jobs: + # Jobs will run only and only if the build action was successful + check-build: + runs-on: windows-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + # Only commits containing [RELEASE] will trigger this action + check-commit: + runs-on: windows-latest + needs: check-build + steps: + - name: Checkout code + - uses: actions/checkout@v3 + + - name: Get Last Commit + run: | + $val = git show --pretty=format:"%s" -s HEAD + echo "MESSAGE=$val" >> $env.GITHUB_ENV + shell: pwsh + + - name: Extract Modules from Commit Message + run: | + $commitMessage = $env:LAST_COMMIT_TITLE + $modules = [regex]::Matches($commitMessage, '(?<=\[RELEASE\] Modules: )([^,]+)') + $moduleList = @() + foreach ($module in $modules) { + $moduleList += $module.Value.Trim() + } + echo "MODULES=$moduleList" >> $env:GITHUB_ENV + shell: pwsh + + - name: Check Last Commit + run: | + if ($env:LAST_COMMIT_TITLE -match '\[RELEASE\]') { + echo "EXECUTABLE=true" >> $env:GITHUB_ENV + } else { + echo "EXECUTABLE=false" >> $env:GITHUB_ENV + } + shell: pwsh + + release: + runs-on: windows-latest + needs: check-commit + env: + MESSAGE: ${{ needs.check-commit.env.MESSAGE }} + MODULES: ${{ needs.check-commit.env.MODULES }} + EXECUTABLE: ${{ needs.check-commit.env.EXECUTABLE }} + if: ${{ env.EXECUTABLE == 'true' }} + + steps: + - name: Checkout code + - uses: actions/checkout@v3 + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '21' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Release modules + run: | + # Iterate over modules + foreach ($module in $env.MODULES) { + echo "Releasing module: $module" + ./gradlew $module:publish $module:closeAndReleaseRepository + } + shell: pwsh + + + + + + + + +