Skip to content
Merged
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
39 changes: 3 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading