From 4c606b6b0c4dd9e7d95c400cacf917c2476edfde Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Fri, 21 Mar 2025 10:23:10 -0400 Subject: [PATCH] Prepare repo for release Update actions to match other libraries. Add change log and PR template for tracking future changes. Set up Dokka multi-module publishing. --- .github/pull_request_template.md | 3 ++ .github/workflows/PR.yml | 25 --------- .github/workflows/SNAPSHOT.yml | 31 ----------- .github/workflows/build.yaml | 42 +++++++++++++++ .github/workflows/release.yaml | 48 +++++++++++++++++ CHANGELOG.md | 89 ++++++++++++++++++++++++++++++++ RELEASING.md | 50 +++++++++++------- build.gradle | 7 +-- core/build.gradle | 4 +- environment/build.gradle | 4 +- gradle.properties | 2 + gradle/gradle-mvn-push.gradle | 10 ---- 12 files changed, 220 insertions(+), 95 deletions(-) create mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/PR.yml delete mode 100644 .github/workflows/SNAPSHOT.yml create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 CHANGELOG.md delete mode 100644 gradle/gradle-mvn-push.gradle diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..e60d0bae --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,3 @@ +--- + +- [ ] `CHANGELOG.md`'s "Unreleased" section has been updated, if applicable. diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml deleted file mode 100644 index 3e9555d0..00000000 --- a/.github/workflows/PR.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version-file: .github/workflows/.java-version - - - uses: gradle/actions/setup-gradle@v4 - - - name: Execute a build - run: ./gradlew build :sample-plugin:buildPlugin --stacktrace - - - run: ./gradlew runPluginVerifier - -env: - GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" diff --git a/.github/workflows/SNAPSHOT.yml b/.github/workflows/SNAPSHOT.yml deleted file mode 100644 index 288a8ed4..00000000 --- a/.github/workflows/SNAPSHOT.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: SNAPSHOT - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version-file: .github/workflows/.java-version - - - uses: gradle/actions/setup-gradle@v4 - - - run: ./gradlew build --stacktrace - - - name: Publish a SNAPSHOT - env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME_APP_CASH }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD_APP_CASH }} - run: ./gradlew publish --no-daemon -Dorg.gradle.parallel=false - -env: - GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..b9c28011 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,42 @@ +name: build + +on: + pull_request: {} + workflow_dispatch: {} + push: + branches: + - 'master' + tags-ignore: + - '**' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version-file: .github/workflows/.java-version + - uses: gradle/actions/setup-gradle@v4 + + - run: ./gradlew build dokkaHtmlMultiModule + + - run: ./gradlew publish + if: ${{ github.ref == 'refs/heads/master' && github.repository == 'sqldelight/sql-psi' }} + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME_APP_CASH }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD_APP_CASH }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }} + + - name: Deploy docs to website + if: ${{ github.ref == 'refs/heads/master' && github.repository == 'sqldelight/sql-psi' }} + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: site + FOLDER: build/dokka/htmlMultiModule + TARGET_FOLDER: docs/latest/ + CLEAN: true \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..09a38e3a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,48 @@ +name: release + +on: + push: + tags: + - '**' + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version-file: .github/workflows/.java-version + - uses: gradle/actions/setup-gradle@v4 + + - run: ./gradlew publish + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME_APP_CASH }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD_APP_CASH }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }} + + - name: Extract release notes + id: extract-release-notes + uses: ffurrer2/extract-release-notes@v2 + with: + release_notes_file: RELEASE_NOTES.md + + - name: Create GitHub release + run: gh release create ${{ github.ref_name }} --notes-file RELEASE_NOTES.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: ./gradlew dokkaHtmlMultiModule + + - name: Deploy docs to website + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: site + FOLDER: build/dokka/htmlMultiModule + TARGET_FOLDER: docs/1.x/ + CLEAN: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..00eee081 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,89 @@ +# Change Log + +## Unreleased + +Nothing yet! + +## 0.4.10 + +## 0.4.9 + +## 0.4.8 + +## 0.4.7 + +## 0.4.6 + +## 0.4.5 + +## 0.4.4 + +## 0.4.3 + +## 0.4.2 + +## 0.4.1 + +## 0.4.0 + +## 0.3.17 + +## 0.3.15 + +## 0.3.14 + +## 0.3.12 + +## 0.3.11 + +## 0.3.10 + +## 0.3.9 + +## 0.3.8 + +## 0.3.7 + +## 0.3.6 + +## 0.3.5 + +## 0.3.4 + +## 0.3.3 + +## 0.3.2 + +## 0.3.1 + +## 0.3.0 + +## 0.2.4 + +## 0.2.3 + +## 0.2.2 + +## 0.2.1 + +## 0.2.0 + +## 0.1.9 + +## 0.1.8 + +## 0.1.7 + +## 0.1.6 + +## 0.1.5 + +## 0.1.4 + +## 0.1.3 + +## 0.1.2 + +## 0.1.1 + +## 0.1.0 diff --git a/RELEASING.md b/RELEASING.md index 5594a042..b788379d 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,25 +1,37 @@ -Releasing -========= +# Releasing - 1. Change the version in `gradle.properties` to a non-SNAPSHOT verson. - 2. Update the `CHANGELOG.md` for the impending release. - 3. Update the `README.md` with the new version. - 4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) - 5. `./gradlew clean publish --no-parallel`. - 6. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact. - 7. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version) - 8. Update the `gradle.properties` to the next SNAPSHOT version. - 9. `git commit -am "Prepare next development version."` - 10. `git push && git push --tags` - 11. Update the sample app to the release version and send a PR. +1. Update the `VERSION_NAME` in `gradle.properties` to the release version. -If step 6 or 7 fails, drop the Sonatype repo, fix the problem, commit, and start again at step 5. +2. Update the `CHANGELOG.md`: + 1. Change the `Unreleased` header to the release version. + 2. Add a link URL to ensure the header link works. + 3. Add a new `Unreleased` section to the top. +3. Commit -Prerequisites -------------- + ``` + $ git commit -am "Prepare version X.Y.Z" + ``` -In `~/.gradle/gradle.properties`, set the following: +4. Tag - * `SONATYPE_NEXUS_USERNAME` - Sonatype username for releasing to `com.squareup`. - * `SONATYPE_NEXUS_PASSWORD` - Sonatype password for releasing to `com.squareup`. + ``` + $ git tag -am "Version X.Y.Z" X.Y.Z + ``` + +5. Update the `VERSION_NAME` in `gradle.properties` to the next "SNAPSHOT" version. + +6. Commit + + ``` + $ git commit -am "Prepare next development version" + ``` + +7. Push! + + ``` + $ git push && git push --tags + ``` + + This will trigger a GitHub Action workflow which will create a GitHub release and upload the + release artifacts to Maven Central. diff --git a/build.gradle b/build.gradle index 15dcb437..fb39ec33 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { alias(libs.plugins.kotlinJvm) apply false alias(libs.plugins.spotless) - alias(libs.plugins.mavenPublish) + alias(libs.plugins.mavenPublish) apply false alias(libs.plugins.dokka) } @@ -29,14 +29,9 @@ allprojects { maven { url "https://cache-redirector.jetbrains.com/intellij-dependencies" } maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies" } } - - group = GROUP - version = VERSION_NAME } subprojects { - apply(plugin: "org.jetbrains.kotlin.jvm") - tasks.withType(JavaCompile).configureEach { sourceCompatibility = '11' targetCompatibility = '11' diff --git a/core/build.gradle b/core/build.gradle index 41ee204b..caf9ef16 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,11 +1,11 @@ plugins { alias(libs.plugins.kotlinJvm) alias(libs.plugins.grammarKitComposer) + alias(libs.plugins.mavenPublish) + alias(libs.plugins.dokka) id("java-test-fixtures") } -apply from: "$rootDir/gradle/gradle-mvn-push.gradle" - grammarKit { intellijRelease.set(libs.versions.ideaVersion) } diff --git a/environment/build.gradle b/environment/build.gradle index 40cc6f4d..9a5acced 100644 --- a/environment/build.gradle +++ b/environment/build.gradle @@ -1,9 +1,9 @@ plugins { alias(libs.plugins.kotlinJvm) + alias(libs.plugins.mavenPublish) + alias(libs.plugins.dokka) } -apply from: "$rootDir/gradle/gradle-mvn-push.gradle" - dependencies { implementation projects.core compileOnly libs.bundles.intelliJ diff --git a/gradle.properties b/gradle.properties index 10239810..f6ee502c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,3 +17,5 @@ POM_DEVELOPER_URL=https://github.com/cashapp SONATYPE_HOST=DEFAULT SONATYPE_AUTOMATIC_RELEASE=true RELEASE_SIGNING_ENABLED=true + +org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle deleted file mode 100644 index 5fab5d11..00000000 --- a/gradle/gradle-mvn-push.gradle +++ /dev/null @@ -1,10 +0,0 @@ -apply plugin: "com.vanniktech.maven.publish" - -publishing { - repositories { - maven { - name = "installLocally" - url = "${rootProject.buildDir}/localMaven" - } - } -}