Skip to content

Commit

Permalink
Change more Gradle config and GitHub Actions workflows
Browse files Browse the repository at this point in the history
- Migrate more files to `kts`
- Use Version Catalogs in all projects
- Rename some Gradle properties in multiple `gradle.properties` files
- Change and improve GitHub Actions workflows
  • Loading branch information
JavierSegoviaCordoba committed Oct 3, 2021
1 parent b965407 commit 633e1aa
Show file tree
Hide file tree
Showing 24 changed files with 158 additions and 188 deletions.
8 changes: 4 additions & 4 deletions .github/scripts/set-env.sh
Expand Up @@ -15,21 +15,21 @@ if [ "$GITHUB_REF" == "refs/heads/main" ]; then
fi

if [ "$LATEST_PUBLISHED_VERSION" == "" ]; then exit 1; fi
RELEASE_VERSION=$(grep LATEST_VERSION $BASEDIR/gradle.properties | cut -d= -f2)
RELEASE_VERSION=$(grep projects.latestVersion $BASEDIR/gradle.properties | cut -d= -f2)
if [ "$LATEST_PUBLISHED_VERSION" != "$RELEASE_VERSION" ]; then NEW_RELEASE_VERSION_EXISTS=1; fi
else
echo "Into release branch ..."
BRANCH_VERSION=$(echo $GITHUB_REF | cut -d/ -f4)
RELEASE_VERSION=$(grep LATEST_VERSION $BASEDIR/gradle.properties | cut -d= -f2)
RELEASE_VERSION=$(grep projects.latestVersion $BASEDIR/gradle.properties | cut -d= -f2)
if [ "$BRANCH_VERSION" == "$RELEASE_VERSION" ]; then
NEW_RELEASE_VERSION_EXISTS=1
else
perl -pe "s/^VERSION_NAME=.*/VERSION_NAME=$BRANCH_VERSION-SNAPSHOT/g" -i $BASEDIR/gradle.properties
perl -pe "s/^projects.version=.*/projects.version=$BRANCH_VERSION-SNAPSHOT/g" -i $BASEDIR/gradle.properties
fi
fi

if [ $NEW_RELEASE_VERSION_EXISTS == 1 ]; then
perl -pe "s/^VERSION_NAME=.*/VERSION_NAME=$RELEASE_VERSION/g" -i $BASEDIR/gradle.properties
perl -pe "s/^projects.version=.*/projects.version=$RELEASE_VERSION/g" -i $BASEDIR/gradle.properties
perl -pe "s/^org.gradle.parallel=.*/org.gradle.parallel=false/g" -i $BASEDIR/gradle.properties
fi

Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/show-env.sh
Expand Up @@ -2,7 +2,7 @@

set -e

# grep VERSION_NAME $BASEDIR/gradle.properties
# grep projects.version $BASEDIR/gradle.properties
echo "LATEST_PUBLISHED_VERSION: $LATEST_PUBLISHED_VERSION"
echo "RELEASE_VERSION: $RELEASE_VERSION"
echo "NEW_RELEASE_VERSION_EXISTS: $NEW_RELEASE_VERSION_EXISTS"
21 changes: 16 additions & 5 deletions .github/workflows/publish.yml
Expand Up @@ -62,7 +62,10 @@ jobs:
working-directory: arrow-libs
run: |
./gradlew publishToSonatype
echo "$(cat $BASEDIR/gradle.properties | grep VERSION_NAME | cut -d'=' -f2) Apple, Linux, JVM & JS deployed!"
echo "$(cat $BASEDIR/gradle.properties | grep projects.version | cut -d'=' -f2) Apple, Linux, JVM & JS deployed!"
- name: Stop Gradle daemons
run: ./gradlew --stop

publish_windows:
runs-on: windows-latest
Expand Down Expand Up @@ -97,7 +100,10 @@ jobs:
working-directory: arrow-libs
run: |
./gradlew publishToSonatype
echo "$(cat gradle.properties | grep VERSION_NAME | cut -d'=' -f2) MingwX64 deployed!"
echo "$(cat gradle.properties | grep projects.version | cut -d'=' -f2) MingwX64 deployed!"
- name: Stop Gradle daemons
run: ./gradlew --stop

publish-arrow-stack:
runs-on: ubuntu-latest
Expand All @@ -107,7 +113,6 @@ jobs:
working-directory: arrow-stack

steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -123,8 +128,11 @@ jobs:

- name: "Publish"
run: |
./gradlew publish
echo "$(cat $BASEDIR/gradle.properties | grep VERSION_NAME | cut -d'=' -f2) Arrow Stack deployed!"
./gradlew publishToSonatype
echo "$(cat $BASEDIR/gradle.properties | grep projects.version | cut -d'=' -f2) Arrow Stack deployed!"
- name: Stop Gradle daemons
run: ./gradlew --stop

publish_doc:
env:
Expand Down Expand Up @@ -258,3 +266,6 @@ jobs:
with:
name: logs
path: arrow-libs/logs

- name: Stop Gradle daemons
run: ./gradlew --stop
55 changes: 13 additions & 42 deletions .github/workflows/pull_request.yml
Expand Up @@ -52,6 +52,9 @@ jobs:
working-directory: arrow-site
run: ./gradlew runAnk

- name: Stop Gradle daemons
run: ./gradlew --stop

linux_jvm_and_js:
runs-on: ubuntu-latest
timeout-minutes: 25
Expand Down Expand Up @@ -93,7 +96,10 @@ jobs:
name: test-reports
path: test-reports

macos_and_ios:
- name: Stop Gradle daemons
run: ./gradlew --stop

apple:
runs-on: macos-latest
timeout-minutes: 20

Expand All @@ -116,7 +122,7 @@ jobs:
- name: Build
working-directory: arrow-libs
run: ./gradlew iosX64Test macosX64Test
run: ./gradlew iosX64Test macosX64Test tvosX64Test watchosX64Test

- name: "Prepare test reports"
if: ${{ always() }}
Expand All @@ -134,46 +140,8 @@ jobs:
name: test-reports
path: test-reports

tv_and_watchos:
runs-on: macos-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Restore Gradle cache
id: cache
uses: actions/cache@v2.1.6
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: tv-watchos-step-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
tv-watch-os-step-gradle-
- name: Build
working-directory: arrow-libs
run: ./gradlew tvosX64Test watchosX64Test

- name: "Prepare test reports"
if: ${{ always() }}
run: |
mkdir test-reports
for report in `ls -d arrow-libs/**/**/build/reports/tests`; do
module=$(echo $report | cut -d/ -f3)
cp -r $report test-reports/$module
done
- name: "Make test reports available to download"
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: test-reports
path: test-reports
- name: Stop Gradle daemons
run: ./gradlew --stop

windows:
runs-on: windows-latest
Expand All @@ -199,3 +167,6 @@ jobs:
- name: Build
working-directory: arrow-libs
run: ./gradlew mingwX64Test

- name: Stop Gradle daemons
run: ./gradlew --stop
6 changes: 3 additions & 3 deletions RELEASE.md
Expand Up @@ -13,8 +13,8 @@ Prepare a pull request with these changes:

1. Update versions in `arrow-libs/gradle.properties`. For instance, the release version will be `0.10.5` and the next SNAPSHOT version will be `0.11.0-SNAPSHOT`:
```
VERSION_NAME=0.11.0-SNAPSHOT
LATEST_VERSION=0.10.5
projects.version=0.11.0-SNAPSHOT
projects.latestVersion=0.10.5
```
2. Update versions in `README.md`
3. Update versions in [the QuickStart section of the website](arrow-site/docs/docs/quickstart/README.md).
Expand Down Expand Up @@ -67,7 +67,7 @@ How to fix a `<major.minor.patch>` version in some of those contexts:
4. Try the new `<major.minor.(patch + 1)-SNAPSHOT>` version.
5. Create a pull request into `main` branch if the fix must be applied to the new versions as well.
6. Create a pull request into `release/<major.minor.(patch + 1)>` branch to release the fix:
* Change just `LATEST_VERSION` in `arrow-libs/gradle.properties`.
* Change just `projects.latestVersion` in `arrow-libs/gradle.properties`.
* Update the version in `README.md`.
* Update the version in [the QuickStart section of the website](arrow-site/docs/docs/quickstart/README.md).
* Update [the sidebar](arrow-site/docs/_data/doc-versions.yml).
Expand Down
2 changes: 0 additions & 2 deletions arrow-libs/build.gradle.kts
Expand Up @@ -12,8 +12,6 @@ plugins {
alias(libs.plugins.arrowGradleConfig.nexus)
}

apply(from = "gradle/main.gradle")

tasks {
val generateDoc by creating(Exec::class) {
group = "documentation"
Expand Down
2 changes: 0 additions & 2 deletions arrow-libs/gradle.properties
@@ -1,8 +1,6 @@
# Package definitions
projects.group=io.arrow-kt
projects.version=1.0.1-SNAPSHOT
# TODO: remove when all projects use `projects.version`
VERSION_NAME=1.0.1-SNAPSHOT
projects.latestVersion=1.0.0
# Versions
ANDROID_LIFECYCLE_VERSION=2.2.0
Expand Down
6 changes: 6 additions & 0 deletions arrow-libs/settings.gradle.kts
Expand Up @@ -26,6 +26,12 @@ pluginManagement {
}

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}

repositories {
mavenCentral()
}
Expand Down
12 changes: 6 additions & 6 deletions arrow-site/build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
apply from: "../arrow-libs/gradle/setup.gradle"
}
dependencies {
classpath "io.arrow-kt:arrow-ank-gradle:$VERSION_NAME"
classpath "io.arrow-kt:arrow-ank-gradle:${property("projects.version")}"
}
}

Expand All @@ -19,13 +19,13 @@ plugins {
apply from: "../arrow-libs/gradle/main.gradle"

dependencies {
implementation "io.arrow-kt:arrow-optics:$VERSION_NAME"
implementation "io.arrow-kt:arrow-core:$VERSION_NAME"
implementation "io.arrow-kt:arrow-fx-coroutines:$VERSION_NAME"
implementation "io.arrow-kt:arrow-fx-stm:$VERSION_NAME"
implementation "io.arrow-kt:arrow-optics:${property("projects.version")}"
implementation "io.arrow-kt:arrow-core:${property("projects.version")}"
implementation "io.arrow-kt:arrow-fx-coroutines:${property("projects.version")}"
implementation "io.arrow-kt:arrow-fx-stm:${property("projects.version")}"
compileOnly "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"

kapt "io.arrow-kt:arrow-meta:$VERSION_NAME"
kapt "io.arrow-kt:arrow-meta:${property("projects.version")}"
}

// Ank Plugin is not applied for every library to avoid adding runtime dependencies
Expand Down
1 change: 0 additions & 1 deletion arrow-site/gradle/wrapper

This file was deleted.

Binary file added arrow-site/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions arrow-site/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
28 changes: 0 additions & 28 deletions arrow-site/settings.gradle

This file was deleted.

41 changes: 41 additions & 0 deletions arrow-site/settings.gradle.kts
@@ -0,0 +1,41 @@
/*
Reason of this file:
The use of Ank Gradle Plugin in the same workspace where is developed.
Details:
Ank Gradle Plugin could be added with project(":arrow-ank-gradle").
However, the problem raises with the things that are done by that plugin.
It adds the dependency of arrow-ank with groupId and all its transitive
dependencies are added as well.
That's the reason why of using this file that replaces those dependencies
with groupId with the correspondent local projects.
*/
enableFeaturePreview("VERSION_CATALOGS")

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}

repositories {
mavenCentral()
}
}

includeBuild("../arrow-libs/") {
dependencySubstitution {
substitute(module("io.arrow-kt:arrow-ank-gradle")).using(project(":arrow-ank-gradle"))
substitute(module("io.arrow-kt:arrow-ank")).using(project(":arrow-ank"))
substitute(module("io.arrow-kt:arrow-core")).using(project(":arrow-core"))
substitute(module("io.arrow-kt:arrow-meta")).using(project(":arrow-meta"))
substitute(module("io.arrow-kt:arrow-fx-stm")).using(project(":arrow-fx-stm"))
substitute(module("io.arrow-kt:arrow-fx-coroutines")).using(project(":arrow-fx-coroutines"))
substitute(module("io.arrow-kt:arrow-optics")).using(project(":arrow-optics"))
}
}

0 comments on commit 633e1aa

Please sign in to comment.