diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 058aaed..f685d19 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -15,15 +15,15 @@ jobs: java: [ 11, 17, 21 ] steps: - - name: Checkout... + - name: Checkout uses: actions/checkout@v4 - - name: Set up JDK... + - name: Set up JDK uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: 'temurin' cache: 'maven' - - name: Build and test... + - name: Build and test run: mvn clean verify -U diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml new file mode 100644 index 0000000..d085a1f --- /dev/null +++ b/.github/workflows/release-prepare.yml @@ -0,0 +1,75 @@ +name: 'prepare release' + +on: + push: + tags: + - '[0-9]+.[0-9]+.?[ab]?[0-9]+' +permissions: + # allow a write access to GitHub Releases + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + + - name: Install build dependencies + run: pip install build + + - name: Build + env: + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_jjava: ${{ github.ref_name }} + run: | + mvn clean verify -U + python -m build + + - name: Collect the release distributions + run: | + mkdir -p release/ + cp jjava/target/jjava-${{ github.ref_name }}-kernelspec.zip release/ + cp -r dist/* release/ + + - name: Store the release distributions + uses: actions/upload-artifact@v4 + with: + name: release-distributions + path: release/ + if-no-files-found: error + + prepare-release: + runs-on: ubuntu-latest + needs: + - build + + steps: + - name: Download distributions + uses: actions/download-artifact@v4 + with: + name: release-distributions + path: release/ + + - name: Create release + id: create_release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + body: JJava ${{ github.ref_name }} release + draft: true + prerelease: false + files: release/* + fail_on_unmatched_files: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8763b09..c37254c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,51 +1,66 @@ -name: 'create release' +name: 'release packages' on: - push: - tags: - - '[0-9]+.[0-9]+*' - -permissions: - # allow a write access to GitHub Releases - contents: write + release: + types: [published] jobs: - prepare-release: + release-pypi: runs-on: ubuntu-latest - - outputs: - tag: ${{ steps.vars.outputs.tag }} - version: ${{ steps.vars.outputs.version }} - upload_url: ${{ steps.create_release.outputs.upload_url }} + permissions: + id-token: write steps: - - name: Checkout... - uses: actions/checkout@v4 - - - name: Set up JDK... - uses: actions/setup-java@v4 + - name: Download release assets + uses: robinraju/release-downloader@v1 with: - java-version: 17 - distribution: 'temurin' - cache: 'maven' + tag: ${{ github.ref_name }} + fileName: jjava-!(kernelspec)*@(.tar.gz|.whl) + out-file-path: dist/ - - name: Build... - run: mvn clean package + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: ${{ runner.debug }} - - name: Set version... - id: vars - run: | - RELEASE_TAG=${GITHUB_REF#refs/*/} - echo "tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT - echo "version=${RELEASE_TAG}" >> $GITHUB_OUTPUT + release-homebrew: + runs-on: ubuntu-latest - - name: Create release... - id: create_release - uses: softprops/action-gh-release@v2 + steps: + - name: Publish package to Homebrew + uses: m-dzianishchyts/brewtap@v1 with: - tag_name: ${{ steps.vars.outputs.tag }} - body: JJava ${{ steps.vars.outputs.version }} release - draft: true - prerelease: false - files: ./jjava/target/jjava-${{ steps.vars.outputs.version }}.zip - fail_on_unmatched_files: true + homebrew_owner: dflib + homebrew_tap: homebrew-tap + version: ${{ github.ref_name }} + depends_on: | + "jupyterlab" + "expect" => :test + target: jjava-${{ github.ref_name }}-kernelspec.zip + install: | + libexec.install Dir["*.jar"] + config = buildpath/"kernel.json" + inreplace config, "{resource_dir}", libexec + system "jupyter kernelspec install #{buildpath} --config=#{config} --sys-prefix --name=java" + test: | + jupyter = Formula["jupyterlab"].opt_bin/"jupyter" + assert_match " java ", shell_output("#{jupyter} kernelspec list") + + (testpath/"console.exp").write <<~EOS + spawn #{jupyter} console --kernel=java + expect -timeout 30 "In " + send "System.out.println(\\\"Hello world!\\\");\r" + expect -timeout 10 "In " + send "\u0004" + expect -timeout 10 "exit" + send "y\r" + EOS + output = shell_output("expect -f console.exp") + assert_match "JJava kernel #{version}", output + assert_match "Hello world!", output + caveats: | + Although JJava doesn't depend on java, it requires jre>=11 to run. + Make sure you have one in your PATH. + update_readme_table: true + github_token: ${{ secrets.HOMEBREW_RELEASE_ACCESS_TOKEN }} + debug: ${{ runner.debug }} diff --git a/install-snapshot.sh b/install-snapshot.sh index 036e318..2ef94c8 100644 --- a/install-snapshot.sh +++ b/install-snapshot.sh @@ -7,9 +7,9 @@ # BUILD_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) -BUILD_DIR="jjava/target/jjava-${BUILD_VERSION}" +BUILD_DIR="jjava/target/jjava-${BUILD_VERSION}-kernelspec" KERNEL_DIR="$(pwd)/${BUILD_DIR}" mvn clean package || exit 1 -unzip -u "${BUILD_DIR}".zip -d "${BUILD_DIR}" || exit 1 -jupyter kernelspec install "${KERNEL_DIR}" --name=java --user || exit 1 +unzip -u "${BUILD_DIR}".zip -d "${BUILD_DIR}" || exit 2 +jupyter kernelspec install "${KERNEL_DIR}" --name=java --user || exit 3 diff --git a/jjava/assembly/zip/zip.xml b/jjava/assembly/kernelspec.xml similarity index 91% rename from jjava/assembly/zip/zip.xml rename to jjava/assembly/kernelspec.xml index a6b3e4d..07e74a1 100644 --- a/jjava/assembly/zip/zip.xml +++ b/jjava/assembly/kernelspec.xml @@ -1,10 +1,7 @@ - zip - - zip - + kernelspec false diff --git a/jjava/pom.xml b/jjava/pom.xml index b6d448a..76daa2d 100644 --- a/jjava/pom.xml +++ b/jjava/pom.xml @@ -34,6 +34,12 @@ + + + src/main/resources + true + + org.apache.maven.plugins @@ -113,16 +119,18 @@ maven-assembly-plugin - assemble-zip + assemble-kernelspec package single - assembly/zip/zip.xml + assembly/kernelspec.xml - false + + zip + diff --git a/jjava/src/main/resources/jjava-kernel-metadata.json b/jjava/src/main/resources/jjava-kernel-metadata.json index f200f68..fb75e8f 100644 --- a/jjava/src/main/resources/jjava-kernel-metadata.json +++ b/jjava/src/main/resources/jjava-kernel-metadata.json @@ -1,4 +1,4 @@ { - "version": "@version@", - "project": "@project@" -} \ No newline at end of file + "version": "${project.version}", + "project": "${project.artifactId}" +} diff --git a/pyproject.toml b/pyproject.toml index 8b70840..e9f18f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta" [project] name = "jjava" -version = "1.0+SNAPSHOT" requires-python = ">=3.8" description = "A Jupyter kernel for Java notebooks" authors = [ @@ -21,6 +20,7 @@ classifiers = [ "Operating System :: POSIX :: Linux", "Operating System :: Microsoft :: Windows" ] +dynamic = ["version"] [project.urls] Documentation = "https://dflib.org/jjava/docs/1.x/" @@ -33,5 +33,8 @@ Changelog = "https://github.com/dflib/jjava/blob/main/RELEASE-NOTES.md" where = ["pip"] include = ["jjava"] +[tool.setuptools_scm] +version_file = "pip/jjava/_version.py" + [tool.setuptools.data-files] "share/jupyter/kernels/java" = ["kernelspec/java/*"]