diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b68b2b393..041421404 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,13 @@ on: branches: [main] pull_request: branches: ['*'] + # release.yml runs the whole CI on the commit it releases. + workflow_call: + inputs: + all: + description: Run every job, ignoring the path filters + type: boolean + default: false env: CARGO_TERM_COLOR: always @@ -13,16 +20,18 @@ jobs: changes: runs-on: ubuntu-latest outputs: - parser: ${{ steps.filter.outputs.parser }} - converters: ${{ steps.filter.outputs.converters }} - cli: ${{ steps.filter.outputs.cli }} - lsp: ${{ steps.filter.outputs.lsp }} - mcp: ${{ steps.filter.outputs.mcp }} - pdf: ${{ steps.filter.outputs.pdf }} - wasm: ${{ steps.filter.outputs.wasm }} + parser: ${{ inputs.all && 'true' || steps.filter.outputs.parser }} + converters: ${{ inputs.all && 'true' || steps.filter.outputs.converters }} + cli: ${{ inputs.all && 'true' || steps.filter.outputs.cli }} + lsp: ${{ inputs.all && 'true' || steps.filter.outputs.lsp }} + mcp: ${{ inputs.all && 'true' || steps.filter.outputs.mcp }} + pdf: ${{ inputs.all && 'true' || steps.filter.outputs.pdf }} + wasm: ${{ inputs.all && 'true' || steps.filter.outputs.wasm }} steps: - uses: actions/checkout@v7 + if: ${{ !inputs.all }} - uses: dorny/paths-filter@v4 + if: ${{ !inputs.all }} id: filter with: filters: | @@ -186,7 +195,14 @@ jobs: test-cli: needs: changes if: needs.changes.outputs.cli == 'true' - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # Release builds don't run tests, so the CLI suite runs on every + # release OS here. libghostty-vt's C++ needs the VS 2022 STL on + # Windows (see the target table in release.yml). + os: [ubuntu-latest, windows-2022, macos-15] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@stable @@ -198,18 +214,26 @@ jobs: env-vars: ImageOS - uses: taiki-e/install-action@nextest - name: Run CLI and execute library tests + if: runner.os == 'Linux' run: cargo nextest run -p acdc-cli -p acdc-execute --all-features --verbose --no-tests warn --test-threads 1 # we've added this until https://github.com/nextest-rs/nextest/pull/3553 gets merged + - name: Run CLI tests + if: runner.os != 'Linux' + run: cargo nextest run -p acdc-cli --all-features --verbose --test-threads 1 --no-fail-fast - name: Run execute-only tests + if: runner.os == 'Linux' run: cargo nextest run -p acdc-cli -p acdc-execute --no-default-features --features execute --verbose --test-threads 1 - name: Test execute with the parser network capability + if: runner.os == 'Linux' run: cargo nextest run -p acdc-execute --no-default-features --features acdc-parser/network -E 'test(substitution_is_independent_of_optional_capabilities)' --verbose - name: Smoke-test backend-only CLI builds + if: runner.os == 'Linux' shell: bash run: | for feature in html manpage markdown pdf terminal; do cargo run -p acdc-cli --no-default-features --features "$feature" -- convert --help done - name: Smoke-test tool-only CLI builds + if: runner.os == 'Linux' shell: bash run: | cargo run -p acdc-cli --no-default-features --features execute -- execute --help @@ -217,8 +241,10 @@ jobs: cargo run -p acdc-cli --no-default-features --features lint -- lint --help cargo run -p acdc-cli --no-default-features --features tck -- tck --help - name: Test native JSON without backends + if: runner.os == 'Linux' run: cargo nextest run -p acdc-cli --no-default-features --test cli --test json_output - name: Test standalone ASG and fixed TCK export + if: runner.os == 'Linux' shell: bash run: | for feature in asg tck; do diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml deleted file mode 100644 index f8f88532e..000000000 --- a/.github/workflows/release-cli.yml +++ /dev/null @@ -1,169 +0,0 @@ -name: Release CLI - -on: - push: - tags: - - 'acdc-cli-v*' - pull_request: - paths: - - '.github/workflows/release-cli.yml' - workflow_dispatch: - -permissions: - contents: read - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - strategy: - fail-fast: false - matrix: - include: - - runner: macos-15 - target: aarch64-apple-darwin - - runner: macos-15-intel - target: x86_64-apple-darwin - - runner: ubuntu-22.04 - target: x86_64-unknown-linux-gnu - - runner: ubuntu-22.04-arm - target: aarch64-unknown-linux-gnu - - runner: windows-2025 - target: x86_64-pc-windows-msvc - runs-on: ${{ matrix.runner }} - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v7 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - uses: mlugg/setup-zig@v2 - with: - version: 0.16.0 - - name: Read package version and check release tag - id: version - env: - REF_TYPE: ${{ github.ref_type }} - run: | - version="$(cargo metadata --no-deps --format-version 1 --locked \ - | jq -er '.packages[] | select(.name == "acdc-cli") | .version')" - if [[ "$REF_TYPE" == "tag" && "$GITHUB_REF_NAME" != "acdc-cli-v${version}" ]]; then - echo "::error::Release tag must match Cargo.toml: acdc-cli-v${version}" - exit 1 - fi - echo "version=${version}" >> "$GITHUB_OUTPUT" - - uses: Swatinem/rust-cache@v2 - with: - env-vars: ImageOS - key: cli-release-${{ matrix.target }} - - uses: taiki-e/install-action@nextest - - name: Test native CLI in release mode - run: cargo nextest run --release -p acdc-cli --all-features --locked --target ${{ matrix.target }} --test-threads 1 - - name: Build and package native CLI - id: package - uses: taiki-e/upload-rust-binary-action@f0d45ae91ee7b8ee928de7a9d04d893a08bcbec6 # v1.30.2 - with: - bin: acdc - package: acdc-cli - target: ${{ matrix.target }} - archive: acdc-${{ steps.version.outputs.version }}-$target - all-features: true - locked: true - include: LICENSE,converters/pdf/crates/theme/assets/fonts/OFL.txt,converters/pdf/crates/theme/assets/fonts/LICENSE-NotoColorEmoji.txt - checksum: sha256 - tar: unix - zip: windows - leading-dir: false - dry-run: true - dry-run-intended: true - - name: Test the extracted archive - env: - ARCHIVE: ${{ steps.package.outputs.tar || steps.package.outputs.zip }} - VERSION: ${{ steps.version.outputs.version }} - run: | - smoke_dir="$(mktemp -d)" - binary=acdc - if [[ "$RUNNER_OS" == "Windows" ]]; then - 7z x "$ARCHIVE" "-o$smoke_dir" - binary=acdc.exe - else - tar -xzf "$ARCHIVE" -C "$smoke_dir" - fi - cmp LICENSE "$smoke_dir/LICENSE" - cmp converters/pdf/crates/theme/assets/fonts/OFL.txt "$smoke_dir/OFL.txt" - cmp converters/pdf/crates/theme/assets/fonts/LICENSE-NotoColorEmoji.txt "$smoke_dir/LICENSE-NotoColorEmoji.txt" - [[ "$(find "$smoke_dir" -type f | wc -l | tr -d ' ')" == 4 ]] - cd "$smoke_dir" - [[ "$(./"$binary" --version)" == "acdc $VERSION" ]] - for command in convert lint inspect execute tck; do - ./"$binary" "$command" --help > /dev/null - done - cat > sample.adoc <<'EOF' - = acdc-smoke(1) - Release Tester - :manmanual: acdc - :mansource: acdc - - == Name - - acdc-smoke - verify release binaries - - == Synopsis - - acdc convert document.adoc - - == Description - - RELEASESMOKETEXT - - [terminal,cols=80,rows=4] - ---- - RELEASETERMINALTEXT - ---- - EOF - for backend in html manpage markdown terminal pdf; do - ./"$binary" convert --backend "$backend" --no-pager --out-file "$backend.out" sample.adoc - test -s "$backend.out" - if [[ "$backend" == pdf ]]; then - [[ "$(head -c 5 "$backend.out")" == '%PDF-' ]] - else - grep -q RELEASESMOKETEXT "$backend.out" - fi - done - grep -q 'class="terminal-view__screen"' html.out - grep -q RELEASETERMINALTEXT terminal.out - - uses: actions/upload-artifact@v7 - with: - name: acdc-cli-${{ matrix.target }} - path: | - ${{ steps.package.outputs.tar }} - ${{ steps.package.outputs.zip }} - ${{ steps.package.outputs.sha256 }} - if-no-files-found: error - - release: - needs: build - if: github.event_name == 'push' && github.ref_type == 'tag' - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v7 - - uses: actions/download-artifact@v8 - with: - pattern: acdc-cli-* - merge-multiple: true - path: dist - - name: Create draft release - env: - GH_TOKEN: ${{ github.token }} - run: | - cd dist - sha256sum --check ./*.sha256 - gh release create "$GITHUB_REF_NAME" ./* \ - --repo "$GITHUB_REPOSITORY" --verify-tag --draft \ - --title "acdc-cli ${GITHUB_REF_NAME#acdc-cli-v}" \ - --notes "Native acdc binaries with all CLI features. Review the changelog and platform checks before publishing." diff --git a/.github/workflows/release-editor-wasm.yml b/.github/workflows/release-editor-wasm.yml deleted file mode 100644 index b66888b7c..000000000 --- a/.github/workflows/release-editor-wasm.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Release editor WASM - -on: - push: - tags: - - 'acdc-editor-wasm-v*' - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - uses: actions/checkout@v7 - - - name: Install toolchain - uses: dtolnay/rust-toolchain@stable - with: - targets: wasm32-unknown-unknown - - - name: Setup Cache - uses: Swatinem/rust-cache@v2 - with: - env-vars: ImageOS - - - name: Install wasm-pack - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - - - name: Build WASM package - run: wasm-pack build acdc-editor-wasm --target web --release - - - name: Extract version - id: version - env: - REF_TYPE: ${{ github.ref_type }} - run: | - if [[ "$REF_TYPE" == "tag" ]]; then - VERSION="${GITHUB_REF_NAME#acdc-editor-wasm-v}" - else - VERSION="$(cargo metadata --no-deps --format-version 1 \ - | jq -r '.packages[] | select(.name == "acdc-editor-wasm") | .version')" - fi - echo "version=v${VERSION}" >> "$GITHUB_OUTPUT" - - - name: Create tarball - env: - VERSION: ${{ steps.version.outputs.version }} - run: tar -czf "acdc-editor-wasm-${VERSION}.tar.gz" -C acdc-editor-wasm/pkg . - - - name: Upload artifact (manual dispatch) - if: github.event_name == 'workflow_dispatch' - uses: actions/upload-artifact@v7 - with: - name: acdc-editor-wasm-${{ steps.version.outputs.version }} - path: acdc-editor-wasm-${{ steps.version.outputs.version }}.tar.gz - - - name: Extract changelog notes - id: notes - env: - VERSION: ${{ steps.version.outputs.version }} - run: | - SEMVER="${VERSION#v}" - NOTES="$(sed -n "/^## \[${SEMVER}\]/,/^## \[/{/^## \[${SEMVER}\]/d;/^## \[/d;p;}" acdc-editor-wasm/CHANGELOG.md)" - { - echo "body<> "$GITHUB_OUTPUT" - - - name: Create GitHub Release - if: github.ref_type == 'tag' - env: - GH_TOKEN: ${{ github.token }} - VERSION: ${{ steps.version.outputs.version }} - RELEASE_NOTES: ${{ steps.notes.outputs.body }} - run: gh release create "$GITHUB_REF_NAME" "acdc-editor-wasm-${VERSION}.tar.gz" --title "acdc-editor-wasm ${VERSION}" --notes-file - <<< "$RELEASE_NOTES" diff --git a/.github/workflows/release-lsp.yml b/.github/workflows/release-lsp.yml deleted file mode 100644 index 455718b48..000000000 --- a/.github/workflows/release-lsp.yml +++ /dev/null @@ -1,110 +0,0 @@ -name: Release LSP - -on: - push: - tags: - - 'acdc-lsp-v*' - pull_request: - paths: - - '.github/workflows/release-lsp.yml' - workflow_dispatch: - -permissions: - contents: read - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - strategy: - fail-fast: false - matrix: - include: - - runner: macos-15 - target: aarch64-apple-darwin - - runner: macos-15-intel - target: x86_64-apple-darwin - - runner: ubuntu-22.04 - target: x86_64-unknown-linux-gnu - - runner: ubuntu-22.04-arm - target: aarch64-unknown-linux-gnu - - runner: windows-2025 - target: x86_64-pc-windows-msvc - runs-on: ${{ matrix.runner }} - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v7 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - name: Read package version and check release tag - id: version - env: - REF_TYPE: ${{ github.ref_type }} - run: | - version="$(cargo metadata --no-deps --format-version 1 --locked \ - | jq -er '.packages[] | select(.name == "acdc-lsp") | .version')" - if [[ "$REF_TYPE" == "tag" && "$GITHUB_REF_NAME" != "acdc-lsp-v${version}" ]]; then - echo "::error::Release tag must match Cargo.toml: acdc-lsp-v${version}" - exit 1 - fi - echo "version=${version}" >> "$GITHUB_OUTPUT" - - uses: Swatinem/rust-cache@v2 - with: - env-vars: ImageOS - key: lsp-release-${{ matrix.target }} - - uses: taiki-e/install-action@nextest - - name: Test native server in release mode - run: cargo nextest run --release -p acdc-lsp --all-features --locked --target ${{ matrix.target }} - - name: Build and package native server - id: package - uses: taiki-e/upload-rust-binary-action@f0d45ae91ee7b8ee928de7a9d04d893a08bcbec6 # v1.30.2 - with: - bin: acdc-lsp - package: acdc-lsp - target: ${{ matrix.target }} - archive: acdc-lsp-${{ steps.version.outputs.version }}-$target - all-features: true - locked: true - include: LICENSE - checksum: sha256 - tar: unix - zip: windows - leading-dir: false - dry-run: true - dry-run-intended: true - - uses: actions/upload-artifact@v7 - with: - name: acdc-lsp-${{ matrix.target }} - path: | - ${{ steps.package.outputs.tar }} - ${{ steps.package.outputs.zip }} - ${{ steps.package.outputs.sha256 }} - if-no-files-found: error - - release: - needs: build - if: github.event_name == 'push' && github.ref_type == 'tag' - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v7 - - uses: actions/download-artifact@v8 - with: - pattern: acdc-lsp-* - merge-multiple: true - path: dist - - name: Create draft release - env: - GH_TOKEN: ${{ github.token }} - run: | - cd dist - sha256sum --check ./*.sha256 - gh release create "$GITHUB_REF_NAME" ./* \ - --repo "$GITHUB_REPOSITORY" --verify-tag --draft \ - --title "acdc-lsp ${GITHUB_REF_NAME#acdc-lsp-v}" \ - --notes "Native acdc-lsp binaries. Review the changelog and platform checks before publishing." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..c717ab4da --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,310 @@ +name: Release + +# Pushing a `release-*` tag (e.g. `release-2026-11-28`) on a commit on main +# releases every crate below whose `-vX.Y.Z` tag doesn't exist yet. The +# full CI and TCK run on that commit while the binaries build, and each crate +# publishes once CI, TCK and all of its builds pass. acdc-parser isn't released +# here; it's published by hand. +# +# Pull requests and pushes to main that change this file build every crate +# without publishing anything. +on: + push: + # GitHub ignores `paths` for tag pushes, so every release tag runs this. + tags: ['release-*'] + branches: [main] + paths: ['.github/workflows/release.yml'] + pull_request: + paths: ['.github/workflows/release.yml'] + +permissions: + contents: read + +concurrency: + group: release-${{ github.ref }} + # Never cancel a release; superseded dry runs can go. + cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }} + +defaults: + run: + shell: bash + +env: + CARGO_TERM_COLOR: always + +jobs: + ci: + uses: ./.github/workflows/ci.yml + with: + all: true + + tck: + uses: ./.github/workflows/tck.yml + + plan: + runs-on: ubuntu-latest + outputs: + releases: ${{ steps.plan.outputs.releases }} + native: ${{ steps.plan.outputs.native }} + wasm: ${{ steps.plan.outputs.wasm }} + targets: ${{ steps.plan.outputs.targets }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - uses: taiki-e/install-action@073e1fd0bc889c9aee68dbaaa927cde1b5653a83 # v2.90.11 + with: + tool: parse-changelog + - name: Find what to release + id: plan + run: | + set -euo pipefail + + # What each native archive holds besides the binary, relative to the + # repository root. + declare -A include=( + [acdc-cli]="LICENSE,acdc-cli/README.adoc,acdc-cli/CHANGELOG.md,converters/pdf/crates/theme/assets/fonts/OFL.txt,converters/pdf/crates/theme/assets/fonts/LICENSE-NotoColorEmoji.txt" + [acdc-lsp]="LICENSE,acdc-lsp/README.md,acdc-lsp/CHANGELOG.md" + [acdc-mcp]="LICENSE,acdc-mcp/README.adoc,acdc-mcp/CHANGELOG.md" + ) + targets=$(jq -c . <<'EOF' + [ + {"target": "aarch64-apple-darwin", "os": "macos-15"}, + {"target": "x86_64-apple-darwin", "os": "macos-15-intel"}, + {"target": "x86_64-unknown-linux-gnu", "os": "ubuntu-22.04"}, + {"target": "aarch64-unknown-linux-gnu", "os": "ubuntu-22.04-arm"}, + {"target": "x86_64-pc-windows-msvc", "os": "windows-2022"} + ] + EOF + ) + + release=false + if [[ $GITHUB_REF == refs/tags/release-* ]]; then + release=true + if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then + echo "::error::${GITHUB_REF#refs/tags/} isn't on main. Tag a commit on main." + exit 1 + fi + fi + + metadata=$(cargo metadata --no-deps --format-version 1 --locked) + releases='[]' + missing_notes=false + for crate in acdc-cli acdc-lsp acdc-mcp acdc-editor-wasm; do + package=$(jq -ec --arg crate "$crate" '.packages[] | select(.name == $crate)' <<<"$metadata") + version=$(jq -er .version <<<"$package") + tag="$crate-v$version" + publish=false + if [[ $release == true ]]; then + # Exit 2 means the tag doesn't exist. Anything else is an error, + # never a reason to release everything. + status=0 + git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null || status=$? + case $status in + 0) echo "$tag is already released"; continue ;; + 2) publish=true ;; + *) echo "::error::Couldn't list the tags on origin"; exit 1 ;; + esac + fi + + if ! parse-changelog "$crate/CHANGELOG.md" "$version" >/dev/null; then + echo "::error::$crate $version has no CHANGELOG section" + missing_notes=true + fi + + if [[ $crate == acdc-editor-wasm ]]; then + kind=wasm bin='' files='' + else + kind=native + bin=$(jq -er '[.targets[] | select(.kind | index("bin")) | .name] | if length == 1 then .[0] else error("expected one binary") end' <<<"$package") + files=${include[$crate]:-} + if [[ -z $files ]]; then + echo "::error::$crate has no packaging entry in release.yml" + exit 1 + fi + fi + releases=$(jq -c \ + --arg crate "$crate" --arg version "$version" --arg tag "$tag" \ + --argjson publish "$publish" --arg kind "$kind" --arg bin "$bin" --arg include "$files" \ + '. + [{$crate, $version, $tag, $publish, $kind} + (if $kind == "native" then {$bin, $include} else {} end)]' \ + <<<"$releases") + done + + if [[ $missing_notes == true ]]; then + exit 1 + fi + if [[ $releases == '[]' ]]; then + echo "::error::Nothing to release: every crate's version is already tagged" + exit 1 + fi + + { + echo "releases=$releases" + echo "native=$(jq -c 'map(select(.kind == "native"))' <<<"$releases")" + echo "wasm=$(jq -c 'map(select(.kind == "wasm")) | first // empty' <<<"$releases")" + echo "targets=$targets" + } | tee -a "$GITHUB_OUTPUT" + + build: + needs: plan + if: needs.plan.outputs.native != '[]' + name: build (${{ matrix.release.crate }}, ${{ matrix.platform.target }}) + strategy: + fail-fast: false + matrix: + release: ${{ fromJSON(needs.plan.outputs.native) }} + platform: ${{ fromJSON(needs.plan.outputs.targets) }} + runs-on: ${{ matrix.platform.os }} + timeout-minutes: 90 + steps: + - uses: actions/checkout@v7 + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.platform.target }} + # libghostty-vt, behind acdc-cli's terminal emulator, builds with zig. + - if: matrix.release.crate == 'acdc-cli' + uses: mlugg/setup-zig@v2 + with: + version: 0.16.0 + # Always a dry run: the action builds and archives, and `publish` uploads + # once everything has passed. + - uses: taiki-e/upload-rust-binary-action@f0d45ae91ee7b8ee928de7a9d04d893a08bcbec6 # v1.30.2 + with: + dry-run: true + dry-run-intended: true + ref: refs/tags/${{ matrix.release.tag }} + bin: ${{ matrix.release.bin }} + package: ${{ matrix.release.crate }} + target: ${{ matrix.platform.target }} + all-features: true + locked: true + archive: ${{ matrix.release.crate }}-$target + leading-dir: true + include: ${{ matrix.release.include }} + checksum: sha256 + # Every runner builds for its own architecture, so the binary that goes + # into the archive can run here. acdc-lsp ignores --version and serves + # on stdin, so it exits as soon as it reads EOF. + - name: Check the binary starts + env: + BIN: target/${{ matrix.platform.target }}/release/${{ matrix.release.bin }}${{ runner.os == 'Windows' && '.exe' || '' }} + run: '"$BIN" --version "$ARCHIVE.sha256" + - uses: actions/upload-artifact@v7 + with: + name: ${{ fromJSON(needs.plan.outputs.wasm).tag }} + path: ${{ env.ARCHIVE }}* + if-no-files-found: error + + publish: + needs: [ci, tck, plan, build, wasm] + # A crate whose build failed doesn't hold back the others; its own + # completeness check below fails instead. + if: ${{ !cancelled() && needs.ci.result == 'success' && needs.tck.result == 'success' && needs.plan.result == 'success' }} + name: publish (${{ matrix.release.tag }}) + strategy: + fail-fast: false + matrix: + release: ${{ fromJSON(needs.plan.outputs.releases) }} + runs-on: ubuntu-latest + permissions: + contents: write + env: + CRATE: ${{ matrix.release.crate }} + VERSION: ${{ matrix.release.version }} + TAG: ${{ matrix.release.tag }} + KIND: ${{ matrix.release.kind }} + PUBLISH: ${{ matrix.release.publish }} + TARGETS: ${{ needs.plan.outputs.targets }} + steps: + - uses: actions/checkout@v7 + - uses: taiki-e/install-action@073e1fd0bc889c9aee68dbaaa927cde1b5653a83 # v2.90.11 + with: + tool: parse-changelog + - if: matrix.release.kind == 'native' + uses: actions/download-artifact@v8 + with: + pattern: ${{ matrix.release.tag }}-* + merge-multiple: true + path: dist + - if: matrix.release.kind == 'wasm' + uses: actions/download-artifact@v8 + with: + name: ${{ matrix.release.tag }} + path: dist + - name: Check every file is there and intact + run: | + set -euo pipefail + missing=() + if [[ $KIND == native ]]; then + for target in $(jq -r '.[].target' <<<"$TARGETS"); do + stem="dist/$CRATE-$target" + [[ -f $stem.sha256 ]] || missing+=("$stem.sha256") + [[ -f $stem.tar.gz || -f $stem.zip ]] || missing+=("$stem.tar.gz or .zip") + done + else + archive="dist/$CRATE-v$VERSION.tar.gz" + [[ -f $archive ]] || missing+=("$archive") + [[ -f $archive.sha256 ]] || missing+=("$archive.sha256") + fi + if (( ${#missing[@]} > 0 )); then + echo "::error::$TAG is missing ${missing[*]}" + exit 1 + fi + cd dist + sha256sum --check --strict -- *.sha256 + - name: Publish the release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + set -euo pipefail + notes="$RUNNER_TEMP/notes.md" + parse-changelog "$CRATE/CHANGELOG.md" "$VERSION" > "$notes" + args=(release create "$TAG" dist/* --target "$GITHUB_SHA" --title "$CRATE $VERSION" --notes-file "$notes") + if [[ $VERSION == *-* ]]; then + args+=(--prerelease) + fi + if [[ $KIND == wasm ]]; then + args+=(--latest=false) + fi + + if [[ $PUBLISH != true ]]; then + echo "Dry run, so not running: gh $(printf '%q ' "${args[@]}")" + ls -l dist + cat "$notes" + exit 0 + fi + + status=0 + git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null || status=$? + case $status in + 0) echo "::notice::$TAG was already released by another run"; exit 0 ;; + 2) gh "${args[@]}" ;; + *) echo "::error::Couldn't list the tags on origin"; exit 1 ;; + esac diff --git a/.github/workflows/tck.yml b/.github/workflows/tck.yml index 8575094b3..59e8fa755 100644 --- a/.github/workflows/tck.yml +++ b/.github/workflows/tck.yml @@ -21,6 +21,8 @@ on: - 'converters/**' - 'Cargo.toml' - 'Cargo.lock' + # release.yml runs the TCK on the commit it releases. + workflow_call: env: CARGO_TERM_COLOR: always diff --git a/AGENTS.md b/AGENTS.md index 4dcdf96fb..bcd5db9cd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -88,8 +88,17 @@ All crates have **independent versions** — bump only crates that changed. The only crate we publish in crates.io is `acdc-parser`. All other crates in this repository are not published. -`acdc-lsp` and `acdc-cli` have separate native release workflows that test five targets and create draft GitHub releases for matching `acdc-lsp-vX.Y.Z` and `acdc-cli-vX.Y.Z` tags. CLI binaries include all features. Manual runs upload artifacts only. Review and publish each draft separately. `acdc-editor-wasm` ships via GitHub Release; the converters and `acdc-converters-dev` are internal workspace members only. +### Releases -### Releasing acdc-editor-wasm +`acdc-cli`, `acdc-lsp`, `acdc-mcp`, and `acdc-editor-wasm` are released by pushing a `release-*` tag on a commit on `main`. `.github/workflows/release.yml` then releases each of these crates whose `-vX.Y.Z` tag doesn't exist yet. It runs the full CI and TCK on that commit while it builds, and publishes each crate's GitHub release once CI, TCK and all of that crate's builds pass. Each native crate is built for five targets with all features; the release notes come from the crate's `CHANGELOG.md`, and publishing creates the crate's tag. `acdc-parser` isn't released this way; publish it to crates.io, and cut its GitHub release, by hand. -Released via GitHub Actions. Bump version in `Cargo.toml`, update changelog, commit, tag `acdc-editor-wasm-vX.Y.Z`, push. +To release, bump each crate's version, move its `[Unreleased]` entries into `## [X.Y.Z] - YYYY-MM-DD`, and push to `main`. Then tag a commit on `main` and push the tag: + +```console +git tag release-YYYY-MM-DD +git push origin release-YYYY-MM-DD +``` + +Use `release-YYYY-MM-DD.2` and so on for a second release on the same day. A release tag that isn't on `main`, has nothing to release, or has a bumped version without a changelog section fails before anything builds. Don't push `-v*` tags by hand: a crate with a tag counts as released. A failed build or CI run publishes nothing for the crates that failed; re-run the failed jobs or push a new release tag to retry. Crates that already published are skipped. + +The target and runner table, and what each archive holds, live in the `plan` job of `release.yml`. Pull requests and pushes to `main` that change `release.yml` build every crate without publishing. The converters and `acdc-converters-dev` are internal workspace members only. diff --git a/acdc-cli/CHANGELOG.md b/acdc-cli/CHANGELOG.md index e19eb051c..60a20eab0 100644 --- a/acdc-cli/CHANGELOG.md +++ b/acdc-cli/CHANGELOG.md @@ -73,6 +73,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Release archives are named `acdc-cli-TARGET.tar.gz` (`.zip` on Windows) with a + matching `.sha256` checksum, and unpack to an `acdc-cli-TARGET` directory that + also holds `README.adoc` and `CHANGELOG.md`. + - The `tck` adapter uses Draft mode and a smaller upstream ASG projection, omitting derived caption state and generated heading IDs that no exported reference uses. Explicit IDs, titles and document caption settings remain; diff --git a/acdc-cli/README.adoc b/acdc-cli/README.adoc index 174fc9708..300d4b159 100644 --- a/acdc-cli/README.adoc +++ b/acdc-cli/README.adoc @@ -28,7 +28,7 @@ cargo build -p acdc-cli --all-features == Native release packaging -The link:../.github/workflows/release-cli.yml[Release CLI workflow] builds `acdc` with `--all-features`. +The link:../.github/workflows/release.yml[release workflow] builds `acdc` with `--all-features`. This includes all five output backends, highlighting, terminal emulation and HTML terminal previews, network support, linting, command execution, inspection, and the TCK adapter. Rust and Zig are build prerequisites; users of the release binary do not need either toolchain. The PDF fonts and Ghostty terminal library are embedded in the binary. @@ -56,27 +56,24 @@ Command execution still needs the interpreter selected by each command block. | Windows x86-64 | `x86_64-pc-windows-msvc` -| `windows-2025` +| `windows-2022` |=== Linux builds target glibc 2.35 or later; older glibc systems and musl-based distributions are not covered by these archives. -The workflow installs Zig 0.16.0 to build the bundled terminal library. -Each platform runs the CLI tests in release mode, then extracts its archive and checks every output backend, including PDF and terminal rendering. +The build installs Zig 0.16.0 for the bundled terminal library. +Windows builds use Visual Studio 2022 because the `windows-2025` image's C++ library rejects Zig 0.16.0's Clang. +Windows binaries link the Visual C++ runtime dynamically, so install the Microsoft Visual C++ Redistributable if `acdc.exe` reports a missing `VCRUNTIME140.dll`. +CI runs the CLI tests on Linux, macOS, and Windows, and every release runs the full CI on the released commit; the release builds themselves don't run tests. -https://github.com/taiki-e/upload-rust-binary-action[upload-rust-binary-action] builds and packages the binaries and calculates SHA-256 checksums. -Archives are named `acdc-X.Y.Z-TARGET.tar.gz` on macOS and Linux, or `acdc-X.Y.Z-TARGET.zip` on Windows. -Each archive contains exactly four files at its root: `acdc` (or `acdc.exe`), `LICENSE`, `OFL.txt`, and `LICENSE-NotoColorEmoji.txt`. +Archives are named `acdc-cli-TARGET.tar.gz` on macOS and Linux, or `acdc-cli-TARGET.zip` on Windows, and each has an `acdc-cli-TARGET.sha256` checksum. +Each archive holds an `acdc-cli-TARGET` directory with `acdc` (or `acdc.exe`), `LICENSE`, `OFL.txt`, `LICENSE-NotoColorEmoji.txt`, `README.adoc`, and `CHANGELOG.md`. The two font notices cover the embedded PDF fonts. -Each target also has an `acdc-X.Y.Z-TARGET.sha256` file. Extract the archive and put the executable in a directory on `PATH`; keep the license files with the distribution. -Manual runs upload build artifacts without creating a release. -A pushed `acdc-cli-vX.Y.Z` tag must match the CLI crate version and creates a *draft* GitHub release after all platform checks pass. -Review the archives and changelog before publishing the draft. -The CLI and LSP use separate workflows, tags, and versions. - -Before tagging a new release, update the CLI crate version and lockfile, and move the relevant changelog entries into its release section. -Use a new tag for each release; do not move an existing tag to newer code. +Releases are cut with a release tag; see "Releases" in link:../AGENTS.md[AGENTS.md]. +Bump the crate version, move the changelog entries into a `## [X.Y.Z] - YYYY-MM-DD` section, push to `main`, then push a `release-YYYY-MM-DD` tag on a commit on `main`. +Once CI, the TCK, and every build pass on that commit, the release workflow publishes the release and creates the `acdc-cli-vX.Y.Z` tag. +Don't push `acdc-cli-v*` tags by hand: a tagged version counts as released, so it would never get any downloads. == Commands diff --git a/acdc-cli/tests/cli.rs b/acdc-cli/tests/cli.rs index 5f051d521..9d5b6fed9 100644 --- a/acdc-cli/tests/cli.rs +++ b/acdc-cli/tests/cli.rs @@ -68,6 +68,24 @@ fn output_text(bytes: &[u8]) -> String { String::from_utf8_lossy(bytes).into_owned() } +/// Undoes miette's line wrapping: it wraps reports at 80 columns and continues +/// them behind a `│` gutter, so long OS messages (such as Windows ones) span +/// several lines. +fn unwrapped(text: &str) -> String { + text.split_whitespace() + .filter(|word| *word != "│") + .collect::>() + .join(" ") +} + +#[test] +fn unwrapped_joins_miette_continuation_lines() { + // Captured from a Windows runner, where the OS message pushes the line + // past miette's 80 columns. + let stderr = " × Parsing error: I/O error: The system cannot find the file specified. (os\r\n │ error 2)\r\n"; + assert!(unwrapped(stderr).contains("The system cannot find the file specified. (os error 2)")); +} + #[cfg(any( feature = "html", feature = "lint", @@ -343,9 +361,12 @@ fn missing_input_file_returns_a_failure() -> Result<(), Box> { let output = run_acdc(&["convert", missing], None)?; let stderr = output_text(&output.stderr); - assert_eq!(output.status.code(), Some(1)); - assert!(stderr.contains(missing)); - assert!(stderr.contains(&read_error.to_string())); + assert_eq!(output.status.code(), Some(1), "{stderr}"); + assert!(stderr.contains(missing), "{stderr}"); + assert!( + unwrapped(&stderr).contains(&unwrapped(&read_error.to_string())), + "expected {read_error:?} in:\n{stderr}" + ); Ok(()) } diff --git a/acdc-cli/tests/json_output.rs b/acdc-cli/tests/json_output.rs index 0900f8714..0d89f47e0 100644 --- a/acdc-cli/tests/json_output.rs +++ b/acdc-cli/tests/json_output.rs @@ -50,18 +50,19 @@ fn native_json_is_available_in_every_build() -> Result<(), Box> { #[test] fn file_and_stdin_use_the_selected_language_mode() -> Result<(), Box> { + let source = "[title=\"*Title*\"]\nText."; let directory = tempfile::tempdir()?; let path = directory.path().join("input.adoc"); - fs::write(&path, "[title=\"*Title*\"]\nText.")?; + fs::write(&path, source)?; for (mode, name, text) in [ ("asciidoctor", "span", "Title"), ("draft", "raw", "*Title*"), ] { for input in ["-", path.to_str().ok_or("path")?] { - let output = run( - &["parse", "--compatibility-mode", mode, input], - "[title=\"*Title*\"]\nText.", - )?; + // A file input never reads stdin, so the process can exit before + // anything is written to it. Only pipe the source for `-`. + let stdin = if input == "-" { source } else { "" }; + let output = run(&["parse", "--compatibility-mode", mode, input], stdin)?; assert!( output.status.success(), "{}", diff --git a/acdc-editor-wasm/CHANGELOG.md b/acdc-editor-wasm/CHANGELOG.md index 08d2b1cbf..db531271b 100644 --- a/acdc-editor-wasm/CHANGELOG.md +++ b/acdc-editor-wasm/CHANGELOG.md @@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Release tarballs ship with a `.sha256` checksum. + - Choose Asciidoctor or Draft spec compatibility in the live editor. Changing the selection updates highlighting, diagnostics, and the preview together. Rust callers can select the same mode with `parse_and_render_with_mode`; the diff --git a/acdc-lsp/CHANGELOG.md b/acdc-lsp/CHANGELOG.md index 08c5ac515..20276145d 100644 --- a/acdc-lsp/CHANGELOG.md +++ b/acdc-lsp/CHANGELOG.md @@ -60,6 +60,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 attributes. Attribute suggestions retain included header values, empty values, and backend-specific defaults. +### Changed + +- Release archives are named `acdc-lsp-TARGET.tar.gz` (`.zip` on Windows) with a + matching `.sha256` checksum, and unpack to an `acdc-lsp-TARGET` directory that + also holds `README.md` and `CHANGELOG.md`. + ### Fixed - Semantic highlighting leading document attributes with a blank line before title. diff --git a/acdc-lsp/README.md b/acdc-lsp/README.md index a2b592b25..7c394e2d4 100644 --- a/acdc-lsp/README.md +++ b/acdc-lsp/README.md @@ -400,25 +400,26 @@ Currently no extension available. Contributions welcome! ## Native release packaging -The [Release LSP workflow](../.github/workflows/release-lsp.yml) tests the server -for macOS ARM64/x86-64, Linux ARM64/x86-64, and Windows x86-64. It uses -[upload-rust-binary-action](https://github.com/taiki-e/upload-rust-binary-action) -to build the release binaries, create archives, and calculate SHA-256 checksums. -Linux builds use Ubuntu 22.04 and require glibc 2.35 or later. - -Archives are named `acdc-lsp-X.Y.Z-TARGET.tar.gz` on macOS and Linux, or -`acdc-lsp-X.Y.Z-TARGET.zip` on Windows. They contain `acdc-lsp` (or -`acdc-lsp.exe`) and the license at their root. Each target also has an -`acdc-lsp-X.Y.Z-TARGET.sha256` file. - -A manual workflow run uploads build artifacts without creating a release. A -pushed `acdc-lsp-vX.Y.Z` tag must match the crate version and creates a **draft** -GitHub release after all platform tests pass. Review the archives and changelog -before publishing the draft. - -Before tagging a new release, update the crate version and lockfile, and move -the relevant changelog entries into its release section. Use a new tag for -each release; do not move an existing tag to newer code. +The [release workflow](../.github/workflows/release.yml) builds the server with +all features for macOS ARM64/x86-64, Linux ARM64/x86-64, and Windows x86-64. +Linux builds use Ubuntu 22.04 and require glibc 2.35 or later. Windows binaries +link the Visual C++ runtime dynamically, so install the Microsoft Visual C++ +Redistributable if `acdc-lsp.exe` reports a missing `VCRUNTIME140.dll`. Every +release runs the full CI on the released commit; the release builds themselves +don't run tests. + +Archives are named `acdc-lsp-TARGET.tar.gz` on macOS and Linux, or +`acdc-lsp-TARGET.zip` on Windows, and each has an `acdc-lsp-TARGET.sha256` +checksum. Each archive holds an `acdc-lsp-TARGET` directory with `acdc-lsp` (or +`acdc-lsp.exe`), `LICENSE`, `README.md`, and `CHANGELOG.md`. + +Releases are cut with a release tag; see "Releases" in [AGENTS.md](../AGENTS.md). +Bump the crate version, move the changelog entries into a +`## [X.Y.Z] - YYYY-MM-DD` section, push to `main`, then push a +`release-YYYY-MM-DD` tag on a commit on `main`. Once CI, the TCK, and every +build pass on that commit, the release workflow publishes the release and +creates the `acdc-lsp-vX.Y.Z` tag. Don't push `acdc-lsp-v*` tags by hand: a +tagged version counts as released, so it would never get any downloads. ## File extensions diff --git a/acdc-mcp/CHANGELOG.md b/acdc-mcp/CHANGELOG.md index 6e4a48ef2..d3ef23f5d 100644 --- a/acdc-mcp/CHANGELOG.md +++ b/acdc-mcp/CHANGELOG.md @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Each release ships prebuilt `acdc-mcp` binaries for Linux and macOS (x86_64 + and aarch64) and Windows (x86_64). + - Select Asciidoctor compatibility (the default) or Draft with `--compatibility-mode asciidoctor|draft`. All document tools use that mode, including includes and table cells. Root and include access rules stay the