Skip to content

Commit

Permalink
💚 I give up
Browse files Browse the repository at this point in the history
Signed-off-by: palexdev <alessandro.parisi406@gmail.com>
  • Loading branch information
palexdev committed Jun 7, 2024
1 parent 6498261 commit f2812d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Build rewrite
name: 'Build rewrite'

on:
push:
Expand Down
52 changes: 28 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: 'Release new versions'
name: 'Release'
on:
workflow_run:
workflows: [ Build rewrite ]
push:
branches: [ rewrite ]
pull_request:
branches: [ rewrite ]
types: [ completed ]

jobs:
# Only if the build action was successful
# Only if last commit contains [RELEASE]
check:
runs-on: windows-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -21,34 +19,36 @@ jobs:
echo "MESSAGE=$val" >> $env.GITHUB_ENV
shell: pwsh

- name: Extract Modules from Commit Message
- name: Check Last Commit
id: check_commit
run: |
$commitMessage = $env:LAST_COMMIT_TITLE
$modules = [regex]::Matches($commitMessage, '(?<=\[RELEASE\] Modules: )([^,]+)')
$moduleList = @()
foreach ($module in $modules) {
$moduleList += $module.Value.Trim()
if ($env:LAST_COMMIT_TITLE -match '\[RELEASE\]') {
echo "::set-output name=executable::true"
} else {
echo "::set-output name=executable::false"
}
echo "MODULES=$moduleList" >> $env:GITHUB_ENV
shell: pwsh

- name: Check Last Commit
- name: Extract Modules from Commit Message
id: extract_modules
run: |
if ($env:LAST_COMMIT_TITLE -match '\[RELEASE\]') {
echo "EXECUTABLE=true" >> $env:GITHUB_ENV
$commitMessage = $env:LAST_COMMIT_TITLE
if ($commitMessage -match '\[RELEASE\] Modules: (.*)') {
$modules = $matches[1] -split ', '
echo "::set-output name=modules::$($modules -join ',')"
} else {
echo "EXECUTABLE=false" >> $env:GITHUB_ENV
echo "::set-output name=modules::"
}
shell: pwsh

outputs:
executable: ${{ steps.check_commit.outputs.executable }}
modules: ${{ steps.extract_modules.outputs.modules }}

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' }}
needs: check
if: ${{ needs.check.outputs.executable == 'true' }}

steps:
- name: Checkout code
Expand All @@ -63,10 +63,14 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -x test -x processCSS

- name: Release modules
run: |
# Iterate over modules
foreach ($module in $env.MODULES) {
$modules = ${{ needs.check.outputs.modules }} -split ','
foreach ($module in $modules) {
echo "Releasing module: $module"
./gradlew $module:publish $module:closeAndReleaseRepository
}
Expand Down

0 comments on commit f2812d4

Please sign in to comment.