-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Icon generation workflow was added.
- Loading branch information
Showing
5 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
MAJOR=`cat $1 | grep "versionMajor" | cut -d'=' -f2` | ||
MINOR=`cat $1 | grep "versionMinor" | cut -d'=' -f2` | ||
PATCH=`cat $1 | grep "versionPatch" | cut -d'=' -f2` | ||
VER=$MAJOR.$MINOR.$PATCH | ||
echo $VER | ||
echo "release_name=$VER" >> $GITHUB_OUTPUT | ||
echo "minor_version=$MINOR" >> $GITHUB_OUTPUT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Update Icons Pack | ||
|
||
#on: | ||
# repository_dispatch: | ||
# types: [ plasma-released ] | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
icons: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# делаем сheckout в текущем репозитория | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
fetch-depth: 0 | ||
path: current | ||
|
||
# делаем сheckout репозитория plasma | ||
- name: Checkout to Plasma Web | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: salute-developers/plasma | ||
ref: dev | ||
show-progress: false | ||
path: plasma | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: 'plasma/.nvmrc' | ||
|
||
- name: Install plasma web project deps | ||
run: | | ||
cd plasma | ||
npm ci | ||
- name: Generate android icons | ||
run: | | ||
cd plasma | ||
npx lerna bootstrap --scope="@salutejs/plasma-icons" --ignore-scripts | ||
npm run generate:android --prefix="packages/plasma-icons" | ||
- name: Extract current version | ||
id: extract_version | ||
working-directory: ./current | ||
shell: bash | ||
run: | | ||
PROPS=./sdds-core/icons/gradle.properties | ||
MAJOR=`cat $PROPS | grep "versionMajor" | cut -d'=' -f2` | ||
MINOR=`cat $PROPS | grep "versionMinor" | cut -d'=' -f2` | ||
PATCH=`cat $PROPS | grep "versionPatch" | cut -d'=' -f2` | ||
VER=$MAJOR.$MINOR.$PATCH | ||
echo $VER | ||
echo "release_name=$VER" >> $GITHUB_OUTPUT | ||
echo "minor_version=$MINOR" >> $GITHUB_OUTPUT | ||
- name: Create release branch | ||
working-directory: ./current | ||
shell: bash | ||
run: | | ||
git branch release/icons-v${{steps.extract_version.outputs.release_name}} develop | ||
git checkout release/icons-v${{steps.extract_version.outputs.release_name}} | ||
- name: Move generated icons to drawable folder | ||
run: | | ||
cp -r plasma/packages/plasma-icons/android-icons/. current/sdds-core/icons/src/main/res/drawable/ | ||
ls current/android-icons | ||
- name: Create tag and release pull request | ||
working-directory: ./current | ||
shell: bash | ||
run: | | ||
TAG=icons-v${{steps.extract_version.outputs.release_name}} | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add ./sdds-core/icons/ | ||
git commit -m "feat(sdds-acore/icons): New icons were added" | ||
git tag -a $TAG -m "Release $TAG" | ||
git push --set-upstream origin release/$TAG | ||
git push origin $TAG | ||
gh pr create --base develop --head release/$TAG |
13 changes: 13 additions & 0 deletions
13
build-system/conventions/src/main/kotlin/convention.auto-bump.gradle.kts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import utils.BumpScope | ||
import utils.bumpVersion | ||
|
||
description = "Convention-плагин, который добавляет таску для автоинкремента версии" | ||
|
||
tasks.register("bump") { | ||
val scope = when(properties["scope"]) { | ||
"major" -> BumpScope.MAJOR | ||
"patch" -> BumpScope.PATCH | ||
else -> BumpScope.MINOR | ||
} | ||
project.bumpVersion(scope) | ||
} |
43 changes: 43 additions & 0 deletions
43
build-system/conventions/src/main/kotlin/utils/AutoBump.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package utils | ||
|
||
import org.gradle.api.Project | ||
|
||
/** | ||
* Область автоинкремента версии | ||
* @author Малышев Александр on 22.03.2024 | ||
*/ | ||
enum class BumpScope { | ||
MAJOR, MINOR, PATCH | ||
} | ||
|
||
/** | ||
* Инкрементирует версию в указанном [scope]. | ||
* Если [scope] == [BumpScope.MINOR], то versionMinor инкрементируется, | ||
* а versionPatch становится равным 0. | ||
* Если [scope] == [BumpScope.MAJOR], то versionMajor инкрементируется, | ||
* * а versionMinor и versionPatch становятся равными 0. | ||
*/ | ||
fun Project.bumpVersion(scope: BumpScope = BumpScope.MINOR) { | ||
val major = properties.getOrDefault("versionMajor", 0).toString().toInt() | ||
val minor = properties.getOrDefault("versionMinor", 0).toString().toInt() | ||
val patch = properties.getOrDefault("versionPatch", 0).toString().toInt() | ||
val updatedProps = file("gradle.properties") | ||
val content = updatedProps.readText() | ||
val newContent = when(scope) { | ||
BumpScope.MAJOR -> { | ||
content | ||
.replace("versionMajor=\\d+".toRegex(), "versionMajor=${major + 1}") | ||
.replace("versionMinor=\\d+".toRegex(), "versionMinor=0") | ||
.replace("versionPatch=\\d+".toRegex(), "versionPatch=0") | ||
} | ||
BumpScope.MINOR -> { | ||
content | ||
.replace("versionMinor=\\d+".toRegex(), "versionMinor=${minor + 1}") | ||
.replace("versionPatch=\\d+".toRegex(), "versionPatch=0") | ||
} | ||
BumpScope.PATCH -> content.replace("versionPatch=\\d+".toRegex(), "versionPatch=${patch + 1}") | ||
} | ||
updatedProps.writeText(newContent) | ||
} | ||
|
||
|
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