Skip to content

Commit

Permalink
No longer build manpage in build scripts
Browse files Browse the repository at this point in the history
Instead, build manpage only as part of the release process to include it
in the release artifacts, and document how to build it during packaing.

This finally removes the OUT_DIR dependency for the release pipeline,
which simplifies and fixes the release pipeline.

Closes GH-284
  • Loading branch information
swsnr committed Jul 28, 2024
1 parent d2d1552 commit 5d94b5b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 71 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,21 @@ jobs:
with:
targets: ${{ matrix.target }}
- run: sudo gem install asciidoctor
if: "!contains(matrix.target, 'windows')"
if: '!contains(matrix.target, "windows")'
- run: sudo apt-get install musl-tools
if: contains(matrix.target, 'linux-musl')
- shell: bash
id: build
run: |
OUTDIR="$(cargo build --locked --target '${{ matrix.target }}' ${{ matrix.cargo_opts }} --release --message-format=json-render-diagnostics |
jq -r 'select(.out_dir) | select(.package_id | startswith("mdcat ")) | .out_dir')"
echo "outdir=$OUTDIR" >>"$GITHUB_OUTPUT"
if: 'contains(matrix.target, "linux-musl")'
- run: cargo build --locked --target '${{ matrix.target }}' ${{ matrix.cargo_opts }} --release
- run: asciidoctor -b manpage -a reproducible mdcat.1.adoc
if: '!contains(matrix.target, "windows")'
- run: strip 'target/${{ matrix.target }}/release/mdcat'
if: "!contains(matrix.target, 'windows')"
if: '!contains(matrix.target, "windows")'
- id: version
shell: bash
run: |
echo "version=$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)" >>"${GITHUB_OUTPUT}"
- id: package
shell: bash
run: ./scripts/package '${{ steps.version.outputs.version }}' '${{ matrix.target }}' '${{ steps.build.outputs.outdir }}'
run: ./scripts/package '${{ steps.version.outputs.version }}' '${{ matrix.target }}'
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.name }}
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ Use `cargo release` to create a new release.
### Added
- mdcat now includes a `--completions` argument to generate shell completions for all major shells (see [GH-286]).

### Fixed
- Restore binary release artifacts (see [GH-284])

### Removed
- mdcat now longer builds shell completions during compilation (see [GH-286]).
- mdcat now longer builds shell completions and man pages during compilation (see [GH-286]).
- Packagers now need to build the manpage explicitly during packaging.
- Release artifacts no longer contain completions; use `mdcat --completions` to generate them instead (see [GH-286]).

[GH-284]: https://github.com/swsnr/mdcat/issues/284
[GH-286]: https://github.com/swsnr/mdcat/pull/286

## [2.2.0] – 2024-07-11
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,10 @@ Try `mdcat --help` or read the [mdcat(1)](./mdcat.1.adoc) manpage.

Run `cargo build --release`.
The resulting `mdcat` executable links against the system's SSL library, i.e. openssl on Linux.

To build a self-contained executable use `cargo build --features=static`; the resulting executable uses a pure Rust SSL implementation.
It still uses the system's CA roots however.

The build process also generates the following additional files in `$OUT_DIR`:

- A `mdcat.1` manpage, build from `mdcat.1.adoc` with the `asciidoctor` command from [AsciiDoctor].
If `asciidoctor` is not found the build script prints a warning.

These additional artifacts are included in the release builds.
If you package mdcat you may want to include these files too.

You may also want to include an `mdless` link to `mdcat` (see above).

[AsciiDoctor]: https://asciidoctor.org/

## Packaging

When packaging `mdcat` you may wish to include the following additional artifacts:
Expand All @@ -105,6 +94,17 @@ When packaging `mdcat` you may wish to include the following additional artifact
$ mdless --completions zsh > /usr/share/zsh/site-functions/_mdless
```

- A build of the man page `mdcat.1.adoc`, using [AsciiDoctor]:

```console
$ asciidoctor -b manpage -a reproducible -o /usr/share/man/man1/mdcat.1 mdcat.1.adoc
$ gzip /usr/share/man/man1/mdcat.1
# If you include a mdless as above, you may also want to support man mdless
$ ln -s mdcat.1.gz /usr/share/man/man1/mdless.1.gz
```

[AsciiDoctor]: https://asciidoctor.org/

## Troubleshooting

`mdcat` can output extensive tracing information when asked to.
Expand Down
46 changes: 0 additions & 46 deletions build.rs

This file was deleted.

3 changes: 1 addition & 2 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ set -exuo pipefail

VERSION="$1"
TARGET="$2"
OUTDIR="$3"

ARCHIVE_NAME="mdcat-${VERSION}-${TARGET}"

Expand Down Expand Up @@ -37,7 +36,7 @@ package_unix() {
cp -r \
README.md CHANGELOG.md LICENSE \
"target/${TARGET}/release/mdcat" \
"${OUTDIR}/mdcat.1" \
"mdcat.1" \
"${pkg_dir}/${ARCHIVE_NAME}"
tar -czf "${PWD}/${archive_file}" -C "${pkg_dir}" "${ARCHIVE_NAME}"
echo "file=${archive_file}" >>"${GITHUB_OUTPUT}"
Expand Down

0 comments on commit 5d94b5b

Please sign in to comment.