fix packaging, add completions/manpage
This commit is contained in:
@@ -6,46 +6,84 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ${{ matrix.info.runs-on }}
|
runs-on: ${{ matrix.info.runs-on }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
info:
|
info:
|
||||||
- os: "macOS-arm"
|
- os: "macOS-arm"
|
||||||
runs-on: "macos-latest"
|
runs-on: "macos-latest"
|
||||||
|
package-extension: "tar.gz"
|
||||||
executable-extension: ""
|
executable-extension: ""
|
||||||
- os: "macOS-intel"
|
- os: "macOS-intel"
|
||||||
runs-on: "macos-26-intel"
|
runs-on: "macos-26-intel"
|
||||||
|
package-extension: "tar.gz"
|
||||||
executable-extension: ""
|
executable-extension: ""
|
||||||
- os: "linux-x86_64"
|
- os: "linux-x86_64"
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
|
package-extension: "tar.gz"
|
||||||
executable-extension: ""
|
executable-extension: ""
|
||||||
- os: "linux-arm"
|
- os: "linux-arm"
|
||||||
runs-on: "ubuntu-24.04-arm"
|
runs-on: "ubuntu-24.04-arm"
|
||||||
|
package-extension: "tar.gz"
|
||||||
executable-extension: ""
|
executable-extension: ""
|
||||||
- os: "Windows-x86_64"
|
- os: "Windows-x86_64"
|
||||||
runs-on: "windows-latest"
|
runs-on: "windows-latest"
|
||||||
|
package-extension: "zip"
|
||||||
executable-extension: ".exe"
|
executable-extension: ".exe"
|
||||||
- os: "Windows-arm"
|
- os: "Windows-arm"
|
||||||
runs-on: "windows-11-arm"
|
runs-on: "windows-11-arm"
|
||||||
|
package-extension: "zip"
|
||||||
executable-extension: ".exe"
|
executable-extension: ".exe"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- name: checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
- name: check version
|
- name: check version
|
||||||
# cut off the v part of the tag to only search for the number
|
# cut off the v part of the tag to only search for the number
|
||||||
run: grep -q "$(echo "${{ github.ref_name }}" | cut -c2-)" Cargo.toml
|
run: grep --quiet "$(echo "${{ github.ref_name }}" | cut -c2-)" Cargo.toml
|
||||||
- run: cargo test --release
|
- name: test
|
||||||
- run: cargo build --release --locked
|
run: cargo test --release
|
||||||
- name: package
|
- name: enable completion/manpage generation
|
||||||
# TODO: include completions/man page
|
run: |
|
||||||
run: tar -azcf "hexapoda-${{ matrix.info.os }}-${{ github.ref_name }}.zip" -C "target/release/" "hexapoda${{ matrix.info.executable-extension }}"
|
mkdir completions
|
||||||
|
export HEXAPODA_COMPLETIONS=completions/
|
||||||
|
mkdir manpage
|
||||||
|
export HEXAPODA_MANPAGE=manpage/
|
||||||
|
- name: build
|
||||||
|
run: cargo build --release --locked
|
||||||
|
- name: package-tar-gz
|
||||||
|
if: ${{ matrix.info.package-extension == "tar.gz" }}
|
||||||
|
run: tar --create --gzip --file "hexapoda-${{ matrix.info.os }}-${{ github.ref_name }}.tar.gz" -C "target/release/" "hexapoda${{ matrix.info.executable-extension }}" -C "." "completions" "manpage"
|
||||||
|
- name: package-zip
|
||||||
|
if: ${{ matrix.info.package-extension == "zip" }}
|
||||||
|
run: |
|
||||||
|
mv "target/release/hexapoda${{ matrix.info.executable-extension }}" "."
|
||||||
|
zip --recurse-paths "hexapoda-${{ matrix.info.os }}-${{ github.ref_name }}.zip" "hexapoda${{ matrix.info.executable-extension }}" "completions" "manpage"
|
||||||
- name: release
|
- name: release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
draft: true
|
draft: true
|
||||||
name: "${{ github.ref_name }}"
|
name: "${{ github.ref_name }}"
|
||||||
files: hexapoda-${{ matrix.info.os }}-${{ github.ref_name }}.zip
|
files: "hexapoda-${{ matrix.info.os }}-${{ github.ref_name }}.${{ matrix.info.package-extension }}"
|
||||||
|
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release
|
||||||
|
steps:
|
||||||
|
- run: echo "publish here!"
|
||||||
|
# permissions:
|
||||||
|
# id-token: write # Required for OIDC token exchange
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v6
|
||||||
|
# - name: check version
|
||||||
|
# # cut off the v part of the tag to only search for the number
|
||||||
|
# # include the " = " to not match on main, only v* tags
|
||||||
|
# run: grep -q " = \"$(echo "${{ github.ref_name }}" | cut -c2-)\"" Cargo.toml
|
||||||
|
# - uses: rust-lang/crates-io-auth-action@v1
|
||||||
|
# id: auth
|
||||||
|
# - run: cargo publish
|
||||||
|
# env:
|
||||||
|
# CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
|
||||||
|
|||||||
+6
-3
@@ -24,23 +24,26 @@ clap_complete = "4.6.3"
|
|||||||
clap_complete_nushell = "4.6.0"
|
clap_complete_nushell = "4.6.0"
|
||||||
clap_mangen = "0.3.0"
|
clap_mangen = "0.3.0"
|
||||||
|
|
||||||
[package.metadata.binstall]
|
|
||||||
pkg-fmt = "zip"
|
|
||||||
|
|
||||||
[package.metadata.binstall.overrides.'cfg(all(target_os = "macos", target_arch = "aarch64" ))']
|
[package.metadata.binstall.overrides.'cfg(all(target_os = "macos", target_arch = "aarch64" ))']
|
||||||
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-macOS-arm-v{ version }{ archive-suffix }"
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-macOS-arm-v{ version }{ archive-suffix }"
|
||||||
|
pkg-fmt = "tgz"
|
||||||
|
|
||||||
[package.metadata.binstall.overrides.'cfg(all(target_os = "macos", target_arch = "x86_64" ))']
|
[package.metadata.binstall.overrides.'cfg(all(target_os = "macos", target_arch = "x86_64" ))']
|
||||||
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-macOS-intel-v{ version }{ archive-suffix }"
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-macOS-intel-v{ version }{ archive-suffix }"
|
||||||
|
pkg-fmt = "tgz"
|
||||||
|
|
||||||
[package.metadata.binstall.overrides.'cfg(all(target_os = "linux", target_arch = "x86_64" ))']
|
[package.metadata.binstall.overrides.'cfg(all(target_os = "linux", target_arch = "x86_64" ))']
|
||||||
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-linux-x86_64-v{ version }{ archive-suffix }"
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-linux-x86_64-v{ version }{ archive-suffix }"
|
||||||
|
pkg-fmt = "tgz"
|
||||||
|
|
||||||
[package.metadata.binstall.overrides.'cfg(all(target_os = "linux", target_arch = "aarch64" ))']
|
[package.metadata.binstall.overrides.'cfg(all(target_os = "linux", target_arch = "aarch64" ))']
|
||||||
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-linux-arm-v{ version }{ archive-suffix }"
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-linux-arm-v{ version }{ archive-suffix }"
|
||||||
|
pkg-fmt = "tgz"
|
||||||
|
|
||||||
[package.metadata.binstall.overrides.'cfg(all(target_os = "windows", target_arch = "x86_64" ))']
|
[package.metadata.binstall.overrides.'cfg(all(target_os = "windows", target_arch = "x86_64" ))']
|
||||||
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-Windows-x86_64-v{ version }{ archive-suffix }"
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-Windows-x86_64-v{ version }{ archive-suffix }"
|
||||||
|
pkg-fmt = "zip"
|
||||||
|
|
||||||
[package.metadata.binstall.overrides.'cfg(all(target_os = "windows", target_arch = "aarch64" ))']
|
[package.metadata.binstall.overrides.'cfg(all(target_os = "windows", target_arch = "aarch64" ))']
|
||||||
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-Windows-arm-v{ version }{ archive-suffix }"
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-Windows-arm-v{ version }{ archive-suffix }"
|
||||||
|
pkg-fmt = "zip"
|
||||||
|
|||||||
@@ -7,20 +7,26 @@ use std::io::Error;
|
|||||||
include!("src/arguments.rs");
|
include!("src/arguments.rs");
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
let output_folder = match env::var_os("OUT_DIR") {
|
let completions_folder = match env::var_os("HEXAPODA_COMPLETIONS") {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
Some(output_folder) => output_folder,
|
Some(folder) => folder,
|
||||||
|
};
|
||||||
|
|
||||||
|
let manpage_folder = match env::var_os("HEXAPODA_MANPAGE") {
|
||||||
|
None => return Ok(()),
|
||||||
|
Some(folder) => folder,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut command = Arguments::command();
|
let mut command = Arguments::command();
|
||||||
for &shell in Shell::value_variants() {
|
for &shell in Shell::value_variants() {
|
||||||
generate_to(shell, &mut command, "hexapoda", &output_folder)?;
|
generate_to(shell, &mut command, "hexapoda", &completions_folder)?;
|
||||||
}
|
}
|
||||||
generate_to(Nushell, &mut command, "hexapoda", &output_folder)?;
|
generate_to(Nushell, &mut command, "hexapoda", &completions_folder)?;
|
||||||
|
|
||||||
clap_mangen::generate_to(command, &output_folder)?;
|
clap_mangen::generate_to(command, &manpage_folder)?;
|
||||||
|
|
||||||
println!("cargo:warning=completions and manpage generated in {output_folder:?}");
|
println!("cargo:warning=completions generated in {completions_folder:?}");
|
||||||
|
println!("cargo:warning=manpage generated in {manpage_folder:?}");
|
||||||
println!("cargo:rerun-if-changed=src/arguments.rs");
|
println!("cargo:rerun-if-changed=src/arguments.rs");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user