From 357e71a84a835ea5e03f22aee3a99d0b50571dc8 Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Thu, 15 Oct 2026 13:46:16 -0700 Subject: [PATCH] Check the Windows launcher before each release, not on every pull request --- .github/workflows/ci.yml | 39 ++------------------------ .github/workflows/release.yml | 53 +++++++++++++++++++++++++++++++++++ CLAUDE.md | 2 +- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff3e967..f655df3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,14 +45,15 @@ jobs: exit 1 fi - # runs the CLI zip's launcher with Java 21, and checks it rejects Java 11 and a missing Java + # runs the CLI zip's launcher with Java 21, and checks it rejects Java 11 and a missing Java. The Windows launcher is + # checked before each release (release.yml), as it rarely changes cli: name: cli (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] steps: - uses: actions/checkout@v7 - uses: actions/setup-java@v6 @@ -69,7 +70,6 @@ jobs: distribution: temurin java-version: 11 - name: Run the launcher - if: runner.os != 'Windows' shell: bash env: JAVA21: ${{ steps.java21.outputs.path }} @@ -81,36 +81,3 @@ jobs: grep -qE 'usage: +dnp3c' help.txt if JAVA_HOME="$JAVA11" ./bin/dnp3c -help; then echo "accepted Java 11"; exit 1; fi if JAVA_HOME="$PWD/none" ./bin/dnp3c -help; then echo "accepted a missing Java"; exit 1; fi - - name: Run the launcher - if: runner.os == 'Windows' - shell: pwsh - env: - JAVA21: ${{ steps.java21.outputs.path }} - JAVA11: ${{ steps.java11.outputs.path }} - run: | - Expand-Archive -Path (Get-Item target/dnp3c-*.zip) -DestinationPath dist - $cli = (Get-ChildItem dist)[0].FullName + "\bin\dnp3c.cmd" - - function Invoke-Cli($javaHome) { - $env:JAVA_HOME = $javaHome - $output = cmd /c "`"$cli`" -help 2>&1" - $output | ForEach-Object { Write-Host $_ } - return @{ Code = $LASTEXITCODE; Output = ($output -join "`n") } - } - - $result = Invoke-Cli $env:JAVA21 - if ($result.Code -ne 0 -or $result.Output -notmatch 'usage:\s+dnp3c') { throw "the launcher failed" } - - # a JAVA_HOME with spaces, like C:\Program Files - New-Item -ItemType Junction -Path "C:\Program Files\Java Under Test" -Target $env:JAVA21 | Out-Null - $result = Invoke-Cli "C:\Program Files\Java Under Test" - if ($result.Code -ne 0 -or $result.Output -notmatch 'usage:\s+dnp3c') { throw "the launcher failed with spaces in JAVA_HOME" } - - $result = Invoke-Cli $env:JAVA11 - if ($result.Code -eq 0) { throw "the launcher accepted Java 11" } - - $result = Invoke-Cli "C:\no java" - if ($result.Code -eq 0) { throw "the launcher accepted a missing Java" } - - # the last case exits with 1 on purpose, which would otherwise fail this step - exit 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f33774c..d57e131 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,60 @@ permissions: contents: write jobs: + # checks the Windows launcher in the CLI zip before anything is published: it runs with Java 21, also from a + # JAVA_HOME with spaces, and rejects Java 11 and a missing Java + windows-launcher: + runs-on: windows-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-java@v6 + id: java21 + with: + distribution: temurin + java-version: 21 + cache: maven + - name: Build the CLI zip + run: mvn -B package -DskipTests + - uses: actions/setup-java@v6 + id: java11 + with: + distribution: temurin + java-version: 11 + - name: Run the launcher + shell: pwsh + env: + JAVA21: ${{ steps.java21.outputs.path }} + JAVA11: ${{ steps.java11.outputs.path }} + run: | + Expand-Archive -Path (Get-Item target/dnp3c-*.zip) -DestinationPath dist + $cli = (Get-ChildItem dist)[0].FullName + "\bin\dnp3c.cmd" + + function Invoke-Cli($javaHome) { + $env:JAVA_HOME = $javaHome + $output = cmd /c "`"$cli`" -help 2>&1" + $output | ForEach-Object { Write-Host $_ } + return @{ Code = $LASTEXITCODE; Output = ($output -join "`n") } + } + + $result = Invoke-Cli $env:JAVA21 + if ($result.Code -ne 0 -or $result.Output -notmatch 'usage:\s+dnp3c') { throw "the launcher failed" } + + # a JAVA_HOME with spaces, like C:\Program Files + New-Item -ItemType Junction -Path "C:\Program Files\Java Under Test" -Target $env:JAVA21 | Out-Null + $result = Invoke-Cli "C:\Program Files\Java Under Test" + if ($result.Code -ne 0 -or $result.Output -notmatch 'usage:\s+dnp3c') { throw "the launcher failed with spaces in JAVA_HOME" } + + $result = Invoke-Cli $env:JAVA11 + if ($result.Code -eq 0) { throw "the launcher accepted Java 11" } + + $result = Invoke-Cli "C:\no java" + if ($result.Code -eq 0) { throw "the launcher accepted a missing Java" } + + # the last case exits with 1 on purpose, which would otherwise fail this step + exit 0 + release: + needs: windows-launcher runs-on: ubuntu-latest env: VERSION: ${{ github.ref_name }} diff --git a/CLAUDE.md b/CLAUDE.md index 5e64fa9..8bafa41 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,7 +46,7 @@ dnp3c is licensed GPL-3.0-only, copyright Step Function I/O LLC. ## Releasing -Pushing a tag releases that version (`.github/workflows/release.yml`): the tag is the version, e.g. `0.1.0`, or `0.1.0-RC1` for a release candidate. The job builds and tests it, publishes `io.stepfunc:dnp3c` to Maven Central, and creates a GitHub release with the CLI zip and the runnable jar. The release's notes are the version's section of `CHANGELOG.md` (a release candidate uses its version's), so add that section before tagging: without it the job stops before publishing. Keep the changelog high level, with an upgrading list for what breaks. Publishing to Central can't be undone, so tag only what's ready. +Pushing a tag releases that version (`.github/workflows/release.yml`): the tag is the version, e.g. `0.1.0`, or `0.1.0-RC1` for a release candidate. A job on Windows first checks the CLI zip's launcher (CI checks only the Linux one). The release job then builds and tests it, publishes `io.stepfunc:dnp3c` to Maven Central, and creates a GitHub release with the CLI zip and the runnable jar. The release's notes are the version's section of `CHANGELOG.md` (a release candidate uses its version's), so add that section before tagging: without it the job stops before publishing. Keep the changelog high level, with an upgrading list for what breaks. Publishing to Central can't be undone, so tag only what's ready. ## Downstream users