Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/actions/classify-pr/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ outputs:
description: Whether the pull request contains CI-related changes
value: ${{ steps.classification.outputs.ci }}
release:
description: Whether the pull request changes version.properties
description: Whether the pull request changes version.json
value: ${{ steps.classification.outputs.release }}
other:
description: Whether the pull request changes something not related to documentation and CI
Expand Down Expand Up @@ -42,10 +42,11 @@ runs:
ci:
- '.github/**'
release:
- 'version.properties'
- 'version.json'
other:
- '**'
- '!docs/**'
- '!README*.md'
- '!zensical.toml'
- '!.github/**'
- '!.github/**'
- '!requirements.*'
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,10 @@ jobs:
with:
report_paths: '**/build/**/TEST-*.xml'

- name: Publish JaCoCo report
uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 # 1.7.2
if: success() || failure()
- name: Upload coverage
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # 5.5.3
with:
paths: '**/build/jacocoReports/**/*.xml'
token: ${{ secrets.GITHUB_TOKEN }}
title: Unit tests coverage
update-comment: true
token: ${{ secrets.CODECOV_TOKEN }}

device-tests:
runs-on: ubuntu-latest
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: github-release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-[a-z0-9]+"

permissions:
contents: read
Expand Down Expand Up @@ -50,6 +51,7 @@ jobs:

- name: Create GitHub release
run: |
gh release create ${{ github.ref_name }} release/* --title ${{ github.ref_name }} --notes-file changelog.txt
gh release create "$TAG" release/* --title "$TAG" --notes-file changelog.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
66 changes: 66 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: publish-docs

on:
pull_request:
types:
- closed
branches:
- master

permissions:
contents: read

jobs:
build-docs:
name: Build documentation
runs-on: ubuntu-latest
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.merged == true

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false
fetch-depth: 0

- name: Setup environment
uses: ./.github/actions/setup-gradle-environment-action
with:
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
python-version: 3.14.3

- name: Prepare API docs
run: |
./gradlew :api-documentation:dokkaGenerate

- name: Build Zensical
run: |
pip3 install --upgrade pip && pip3 install -r requirements.txt
zensical build

- name: Upload docs artifact
uses: actions/upload-pages-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
path: site

deploy-docs:
name: Publish documentation
needs: [ build-docs ]
runs-on: ubuntu-latest

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy docs
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # 5.0.0
78 changes: 6 additions & 72 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
name: publish

on:
pull_request:
types:
- closed
branches:
- master
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-[a-z0-9]+"

permissions:
contents: read

jobs:
classify:
name: Classify pull request
runs-on: ubuntu-latest

permissions:
pull-requests: read

outputs:
release: ${{ steps.classify.outputs.release }}

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
repository: ${{ github.event.pull_request.base.repo.full_name }}
ref: ${{ github.event.pull_request.base.ref }}
persist-credentials: false

- name: Classify pull request
id: classify
uses: ./.github/actions/classify-pr

publish:
name: Upload artifacts
runs-on: ubuntu-latest
needs: [ classify ]
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.merged == true && needs.classify.outputs.release == 'true'
if: github.repository == 'solrudev/Ackpine'

steps:
- name: Checkout
Expand All @@ -58,46 +34,4 @@ jobs:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}

publish-docs:
name: Publish documentation
runs-on: ubuntu-latest
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.merged == true

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false
fetch-depth: 0

- name: Setup environment
uses: ./.github/actions/setup-gradle-environment-action
with:
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
python-version: 3.14.3

- name: Prepare API docs
run: |
./gradlew :api-documentation:dokkaGenerate

- name: Build Zensical
run: |
pip3 install --upgrade pip && pip3 install zensical
zensical build

- name: Deploy docs
if: success()
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # 4.8.0
with:
branch: gh-pages
folder: site
single-commit: true
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
18 changes: 17 additions & 1 deletion .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,26 @@ jobs:
fetch-depth: '0'
persist-credentials: false

- name: Read version.json
id: version
run: |
is_snapshot=$(jq -r '.isSnapshot' version.json)
if [ "$is_snapshot" = "true" ]; then
echo "::error::Snapshot versions cannot be released"
exit 1
fi
version=$(
jq -r '
"\(.majorVersion).\(.minorVersion).\(.patchVersion)"
+ (if (.suffix // "") != "" then "-\(.suffix)" else "" end)
' version.json
)
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Push tag
uses: anothrNick/github-tag-action@4ed44965e0db8dab2b466a16da04aec3cc312fd8 # 1.75.0
env:
GITHUB_TOKEN: ${{ secrets.PAT_AUTOTAG }}
CUSTOM_TAG: ${{ github.event.pull_request.title }}
CUSTOM_TAG: ${{ steps.version.outputs.version }}
WITH_V: false
PRERELEASE: false
1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

plugins {
`kotlin-dsl`
alias(libs.plugins.kotlin.serialization)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.registerIfAbsent

/**
* Returns a provider of a [Version] object parsed from `version.properties` file in root project directory.
* Returns a provider of a [Version] object parsed from `version.json` file in root project directory.
*/
public val Project.ackpineVersion: Provider<Version>
get() = gradle
.sharedServices
.registerIfAbsent("versioning", VersioningService::class) {
parameters.versionFile = layout.settingsDirectory.file("version.properties")
parameters.versionFile = layout.settingsDirectory.file("version.json")
}
.map { service ->
service.version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@

package ru.solrudev.ackpine.gradle.versioning

import kotlinx.serialization.Serializable

private val validSuffix = Regex("[a-z0-9]*")

/**
* Version of the project, adhering to semantic versioning.
*/
@Serializable
public data class Version(
public val majorVersion: Int,
public val minorVersion: Int,
Expand Down Expand Up @@ -49,17 +54,20 @@ public data class Version(
}

private fun computeVersionCode(): Int {
if (!suffix.matches(validSuffix)) {
error("Version suffix contains illegal characters: $suffix")
}
val suffixBase = when {
suffix.startsWith("dev") -> 0
suffix.startsWith("alpha") -> 1
suffix.startsWith("beta") -> 2
suffix.startsWith("rc") -> 8
suffix.isEmpty() -> 9
else -> error("Unknown version suffix")
else -> error("Unknown version suffix: $suffix")
}
val suffixVersionIndex = suffix.indexOfFirst { it.isDigit() }
if (suffix.isNotEmpty() && suffixVersionIndex == -1) {
error("No suffix version found")
error("No suffix version found: $suffix")
}
val suffixVersion = if (suffixVersionIndex != -1) suffix.substring(suffixVersionIndex).toInt() else 0
val snapshot = if (isSnapshot) 0 else 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@

package ru.solrudev.ackpine.gradle.versioning

import kotlinx.serialization.json.Json
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
import ru.solrudev.ackpine.gradle.helpers.getOrThrow
import ru.solrudev.ackpine.gradle.helpers.readProperties

internal abstract class VersioningService : BuildService<VersioningService.Parameters> {

private val json = Json { ignoreUnknownKeys = false }

internal val version by lazy {
val versionProperties = parameters.versionFile.get().asFile.readProperties()
val majorVersion = versionProperties.getOrThrow("MAJOR_VERSION").toInt()
val minorVersion = versionProperties.getOrThrow("MINOR_VERSION").toInt()
val patchVersion = versionProperties.getOrThrow("PATCH_VERSION").toInt()
check("SUFFIX" in versionProperties.keys) { "SUFFIX was not provided" }
val suffix = (versionProperties["SUFFIX"] as String).lowercase()
val isSnapshot = versionProperties.getOrThrow("SNAPSHOT").toBooleanStrict()
Version(majorVersion, minorVersion, patchVersion, suffix, isSnapshot)
val versionJson = parameters.versionFile.get().asFile.readText()
json.decodeFromString<Version>(versionJson)
}

internal interface Parameters : BuildServiceParameters {
Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
comment:
layout: "header, files, footer"
hide_project_coverage: false
7 changes: 6 additions & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ Projects are added to `:api-documentation:dokkaGenerate` task through `dependenc

## Documentation website

To serve documentation website on localhost, execute this command (requires Python 3 and Zensical to be installed):
Documentation is built using Zensical (requires Python 3). To install Zensical locally, you can use this command while you're in the Ackpine repository root directory:
```
pip3 install -r requirements.txt
```

To serve documentation website on localhost, execute this command:
```
zensical serve
```
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zensical
Loading
Loading