Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: version 1.1.0 #56

Merged
merged 28 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b4d95fb
feat: add semanatic release setup
vgarciabnz Feb 5, 2024
3e2fc45
refactor: consolidate github flows
vgarciabnz Feb 6, 2024
1f247d9
update github action versions
vgarciabnz Feb 7, 2024
63d5e66
refactor: add private=false to package.json
vgarciabnz Feb 8, 2024
c9ae07a
Merge pull request #46 from dhis2/semantic-release
vgarciabnz Feb 8, 2024
adb01a9
fix: separate Nyx config file
vgarciabnz Feb 14, 2024
66f5e17
Merge pull request #47 from dhis2/explicit-nyx-config
vgarciabnz Feb 14, 2024
9adc58c
fix: ship esmodule and commonjs
vgarciabnz Feb 19, 2024
fb4379e
Merge pull request #49 from dhis2/ship-esmodule-commonjs
vgarciabnz Feb 19, 2024
1b2fa95
fix: remove shortcut exit
vgarciabnz Feb 19, 2024
c06625c
fix: do not generate types in commonjs build
vgarciabnz Feb 19, 2024
5981235
feat: contains and containsItems [DHIS2-16211]
jimgrace Mar 3, 2024
9992e91
fix: contains and containsItems with explicit pattern argument and re…
jbee Mar 4, 2024
657a867
Merge pull request #51 from dhis2/DHIS2-16211
jbee Mar 4, 2024
fff002a
fix: use JsMap wrapper (JS component) (#52)
vgarciabnz Apr 10, 2024
69d0ca0
Update readme explaining semantic release setup
vgarciabnz Apr 10, 2024
5641600
feat! enum ID.Type as top level IDType
jbee Apr 10, 2024
2027ba7
feat! enum ID.Type as top level IDType
jbee Apr 10, 2024
714917d
chore: use ID and IDType in JS API (as they are not exported)
jbee Apr 10, 2024
62d96be
Update README.md
vgarciabnz Apr 10, 2024
89014c7
chore: move enums to spi, use enums in JS API
jbee Apr 10, 2024
10896af
feat! Expression.Mode as top level enum ExpressionMode
jbee Apr 10, 2024
f64d6a6
fix: use newer kotlin version without enum JS bug
jbee Apr 10, 2024
c212722
chore: opt-in to @JsExport in build setup
jbee Apr 10, 2024
f7a7a69
Merge pull request #54 from jbee/enums-top-level
jbee Apr 11, 2024
1f603f4
Add missing PGP variables
vgarciabnz Apr 11, 2024
3d6fa48
Merge pull request #55 from dhis2/add-signing-keys
vgarciabnz Apr 11, 2024
b9b5f03
Merge pull request #53 from dhis2/dev-process-readme
vgarciabnz Apr 11, 2024
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
28 changes: 28 additions & 0 deletions .github/workflows/job-check-new-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
workflow_call:
outputs:
isNewVersion:
description: "Indicates if this build generates a new version"
value: ${{ jobs.check-new-version.outputs.isNewVersion }}

jobs:
check-new-version:
name: Check new version
runs-on: ubuntu-latest
outputs:
isNewVersion: ${{ steps.newVersion.outputs.isNewVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew
- id: newVersion
name: Check new version
run: ./.github/workflows/scripts/check-new-version.sh
41 changes: 41 additions & 0 deletions .github/workflows/job-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
workflow_call

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew

- uses: actions/setup-node@v4
with:
node-version: 14.x

- name: Create tag and publish Github release
run: ./gradlew :nyxPublish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Maven
run: ./.github/workflows/scripts/publish-maven.sh
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
SIGNING_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.PGP_PASSPHRASE }}

- name: Publish NPMJS
run: ./.github/workflows/scripts/publish-npm.sh
env:
NPMJS_TOKEN: ${{ secrets.DHIS2_BOT_NPM_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/job-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_call

jobs:
unit-test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew
- name: Test
run: ./gradlew clean allTests
44 changes: 12 additions & 32 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
name: Run tests
name: Main

on:
push:
branches:
- 'main'
- 'beta'

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew
- name: Test
run: ./gradlew clean allTests
publish:
name: Publish - Nexus
runs-on: ubuntu-latest
uses: ./.github/workflows/job-test.yml

check-new-version:
needs: unit-test
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew
- name: Release Maven package
run: ./gradlew publishAllPublicationsToSonatypeRepository
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
uses: ./.github/workflows/job-check-new-version.yml

publish:
needs: check-new-version
if: ${{ needs.check-new-version.outputs.isNewVersion == 'true' }}
uses: ./.github/workflows/job-publish.yml
secrets: inherit
14 changes: 1 addition & 13 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,4 @@ on: [pull_request]

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew
- name: Test
run: ./gradlew clean allTests
uses: ./.github/workflows/job-test.yml
8 changes: 8 additions & 0 deletions .github/workflows/scripts/check-new-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Check if new version
./gradlew checkIsNewVersion -q; newVersion=$?

if [ $newVersion -ne 0 ]; then
echo "isNewVersion=false" >> "$GITHUB_OUTPUT"
else
echo "isNewVersion=true" >> "$GITHUB_OUTPUT"
fi
9 changes: 9 additions & 0 deletions .github/workflows/scripts/publish-maven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -x

branch=$(git rev-parse --abbrev-ref HEAD)

if [ "$branch" = "main" ]; then
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
elif [ "$branch" = "beta" ]; then
./gradlew publishToSonatype -PbetaToSnapshot
fi
17 changes: 17 additions & 0 deletions .github/workflows/scripts/publish-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set -x

branch=$(git rev-parse --abbrev-ref HEAD)

./gradlew packJsPackage
./gradlew packJsPackage -PuseCommonJs

cd build/packages/js || exit

# Set authentication token for npmjs registry
npm set //registry.npmjs.org/:_authToken="$NPMJS_TOKEN"

if [ "$branch" = "main" ]; then
npm publish
elif [ "$branch" = "beta" ]; then
npm publish --tag beta
fi
57 changes: 57 additions & 0 deletions .nyx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# starting from the "simple" preset gives us:
# - the Conventional Commits convention
preset: "simple"
changelog:
path: "CHANGELOG.md"
sections:
"Added": "^feat$"
"Fixed": "^fix$"
releaseTypes:
enabled:
- mainline
- maturity
- internal
publicationServices:
- github
items:
mainline:
description: "{{#fileContent}}CHANGELOG.md{{/fileContent}}"
filterTags: "^({{configuration.releasePrefix}})?([0-9]\\d*)\\.([0-9]\\d*)\\.([0-9]\\d*)$"
gitPush: "true"
gitTag: "true"
matchBranches: "^(master|main)$"
matchEnvironmentVariables:
CI: "^true$"
matchWorkspaceStatus: "CLEAN"
publish: "true"
maturity:
description: "{{#fileContent}}CHANGELOG.md{{/fileContent}}"
collapseVersions: true
collapsedVersionQualifier: "{{#sanitizeLower}}{{branch}}{{/sanitizeLower}}"
filterTags: "^({{configuration.releasePrefix}})?([0-9]\\d*)\\.([0-9]\\d*)\\.([0-9]\\d*)(-(alpha|beta)(\\.([0-9]\\d*))?)?$"
gitPush: "true"
gitTag: "true"
matchBranches: "^(alpha|beta)$"
matchEnvironmentVariables:
CI: "^true$"
matchWorkspaceStatus: "CLEAN"
publish: "true"
publishPreRelease: "true"
internal:
collapseVersions: true
collapsedVersionQualifier: "internal"
gitPush: "false"
gitTag: "false"
identifiers:
-
qualifier: "{{#timestampYYYYMMDDHHMMSS}}{{timestamp}}{{/timestampYYYYMMDDHHMMSS}}"
position: "BUILD"
publish: "false"
services:
github:
type: "GITHUB"
options:
AUTHENTICATION_TOKEN: "{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}"
REPOSITORY_NAME: "expression-parser"
REPOSITORY_OWNER: "dhis2"
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,24 @@ To select which expression is used the `Expression` is parameterized with a `Mod
* `PROGRAM_INDICATOR_EXPRESSION`: Computes a number for a program indicator expression (persisted aggregate data computation)
* `RULE_ENGINE_CONDITION`: Computes a boolean to check if a rule applies
* `RULE_ENGINE_ACTION`: Computes a boolean, string, number or date from a rule

## Development
This library implements the semantic release setup, which means that version numbers are not manually maintained but
derived from the commit/PR history.

Branches:
- `main`: a push to `main` branch will trigger a new production release (both Maven and NPMJS).
- `beta`: a push to `beta` branch will trigger a SNAPSHOT release in Maven and a new beta release in NPMJS.

Version number are determined by the presence of commits with these suffixes:
- `fix:`: it will increase the patch number.
- `feat:`: it will increase the minor version number.
- `feat!:`: it will increase the major version number.

If there is not any commit with any of this tags between the previous version and the current commit, nothing will be published.

Typical workflow:
1. Do work in a feature branch. There is no need to add tags to the commits.
2. Create a PR to `beta` branch including a tag in the PR title depending on the kind of changes.
3. Merge the PR using **Squash and merge**. It will publish a SNAPSHOT/BETA release if there is a version change.
4. Create a PR to `main` branch. Once merged, it will publish a production release.
39 changes: 32 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.mooltiverse.oss.nyx.gradle.CoreTask

plugins {
kotlin("multiplatform")
id("maven-publish-conventions")
Expand All @@ -9,11 +11,21 @@ repositories {
}

group = "org.hisp.dhis.lib.expression"
version = "1.1.0-SNAPSHOT"

val isReleaseVersion = project.hasProperty("removeSnapshot")
if (isReleaseVersion) {
version = (version as String).replace("-SNAPSHOT", "")
if (project.hasProperty("betaToSnapshot")) {
val mainVersion = (version as String).split("-beta")[0]
version = "$mainVersion-SNAPSHOT"
}

tasks.register("checkIsNewVersion") {
val state = project.properties[CoreTask.NYX_STATE_PROPERTY] as com.mooltiverse.oss.nyx.state.State

if (state.newVersion) {
println("This build generates a new version ${state.version}")
} else {
println("This build does not generate a new version ${state.version}")
throw StopExecutionException("There is no new version")
}
}

kotlin {
Expand All @@ -28,9 +40,13 @@ kotlin {
}
js {
nodejs()
useEsModules()
if (project.hasProperty("useCommonJs")) {
useCommonJs()
} else {
useEsModules()
generateTypeScriptDefinitions()
}
binaries.library()
generateTypeScriptDefinitions()
}
val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
Expand All @@ -46,6 +62,11 @@ kotlin {


sourceSets {
all {
languageSettings.apply {
optIn("kotlin.js.ExperimentalJsExport")
}
}
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
Expand All @@ -59,7 +80,11 @@ kotlin {
}
val jvmMain by getting
val jvmTest by getting
val jsMain by getting
val jsMain by getting {
dependencies {
api("org.jetbrains.kotlin-wrappers:kotlin-js:1.0.0-pre.722")
}
}
val jsTest by getting
val nativeMain by getting
val nativeTest by getting
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.0")
implementation("io.github.gradle-nexus:publish-plugin:1.3.0")
implementation("dev.petuska:npm-publish-gradle-plugin:3.4.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD")
val signingPrivateKey: String? = System.getenv("SIGNING_PRIVATE_KEY")
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")

val isReleaseVersion = (version as String).contains("SNAPSHOT")

val dokkaHtml = tasks.findByName("dokkaHtml")!!

val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") {
Expand Down Expand Up @@ -68,7 +66,7 @@ nexusPublishing {
}

signing {
isRequired = isReleaseVersion
setRequired({ !version.toString().endsWith("-SNAPSHOT") })
useInMemoryPgpKeys(signingPrivateKey, signingPassword)
sign(publishing.publications)
}
Loading