Skip to content
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
java_version: |
25
21
npm_version: ${{ needs.build.outputs.npm_version }}
secrets:
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
npm_token: ${{ secrets.NPM_TOKEN }}
6 changes: 6 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
type: boolean
required: false
default: false
npm_version:
description: Exact npm package version to publish (passed from build/release job)
type: string
required: false
default: ''
secrets:
gradle_enterprise_access_key:
required: false
Expand Down Expand Up @@ -64,6 +69,7 @@ jobs:
./gradlew ${{ env.GRADLE_SWITCHES }}
:rewrite-javascript:npmPack
${{ inputs.releasing && '-Preleasing' || '' }}
${{ inputs.npm_version && format('-PnpmVersion={0}', inputs.npm_version) || '' }}

- name: npm publish
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
25
21
releasing: true
npm_version: ${{ needs.release.outputs.npm_version }}
secrets:
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
npm_token: ${{ secrets.NPM_TOKEN }}
19 changes: 15 additions & 4 deletions rewrite-csharp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,21 @@ tasks.withType<Test> {
// Generate a NuGet-compatible version
// Snapshots use pre-release suffix with timestamp: 8.73.0-snapshot.20260110143252
// Releases use clean version: 8.73.0
val nugetVersion: String = project.version.toString().replace(
"-SNAPSHOT",
"-snapshot.${LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))}"
)
// Read from version.txt first (written by a prior `build` invocation) to ensure the
// version published to NuGet matches what's baked into the JAR.
val nugetVersionTxt = file("src/main/resources/META-INF/rewrite-csharp-version.txt")
val nugetVersion: String = if (System.getenv("CI") != null) {
nugetVersionTxt.takeIf { it.exists() }?.readText()?.trim()?.takeIf { it.isNotEmpty() }
?: project.version.toString().replace(
"-SNAPSHOT",
"-snapshot.${LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))}"
)
} else {
project.version.toString().replace(
"-SNAPSHOT",
"-snapshot.${LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))}"
)
}

val generateVersionTxt by tasks.registering {
group = "csharp"
Expand Down
11 changes: 7 additions & 4 deletions rewrite-javascript/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ extensions.configure<NodeExtension> {
nodeProjectDir.set(projectDir.resolve("rewrite"))
}

// Read the version from the version.txt written on disk by a prior build, or generate a fresh
// timestamped version. This ensures the second Gradle invocation (`snapshot publish`) publishes
// the same version that the first invocation (`build`) baked into the JAR.
// Determine the npm package version. Priority:
// 1. Gradle property `npmVersion` (set by CI workflows to pass the version across jobs)
// 2. version.txt on disk (written by a prior `build` invocation in the same job)
// 3. Generate a fresh timestamped version from project.version
val versionTxt = file("src/main/resources/META-INF/rewrite-javascript-version.txt")
val datedSnapshotVersion: String = if (System.getenv("CI") != null) {
val datedSnapshotVersion: String = if (project.hasProperty("npmVersion")) {
project.property("npmVersion").toString()
} else if (System.getenv("CI") != null) {
versionTxt.takeIf { it.exists() }?.readText()?.trim()?.takeIf { it.isNotEmpty() }
?: project.version.toString().replace(
"SNAPSHOT",
Expand Down